Golang newbie - keen to contribute

Hi all, I’m new to Go programming and want to contribute to Hugo.
Working my way through the Contribute to Hugo Development article and I’ve run into a problem:

mage -v check fails in go1.17.1 on Windows with this error:
cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%

This looks like a previous Hugo issue: Compiling and installing Hugo from source on Windows is getting a gcc error and fails · Issue #5798 · gohugoio/hugo · GitHub, which was closed and referred here, so am reluctant to open a new one (for now at least!)

I think the root cause is this Golang issue: cmd/dist: remove precompiled .a files from binary distributions · Issue #47257 · golang/go · GitHub and I have the beginnings of an idea to resolve it in Hugo. I’m keen for any input and guidance the community can offer, and looking forward to getting involved!

You no longer need mage to build Hugo from source.

No idea what’s going on with that article (I don’t contribute to the Docs) maybe the others have reasons for not updating it (cc: @jmooring ).

Provided that you have Go installed and an up-to-date local clone of the Hugo master repository then from within that directory simply execute the following command in the console:

go build 

Or if you need the Hugo extended version run:

go build -tags extended

With the above you will get the latest Hugo-DEV version from source.

And that’s it really.

P.S. Since GitHub introduced a simple button in their web GUI to fetch the latest from upstream I simply use it and then locally from within my Hugo fork I simply run git pull to fetch the latest.

Thanks for the tip re mage, I’ll treat that article with caution. (Happy to help with a rewrite if that’s needed – once I get my head around this.)

At this point though I don’t think mage is the problem. go build works fine for me, whether mage executes it, or I run it direct.

The error occurs on go test -race ./... and it’s the same whether triggered by mage or run direct.

Additional info:

Here’s the full command issued by mage:

go test -race ./... -buildmode exe -tags none

Again, this produces the same error when I run it direct.

You need a C compiler when building the extended version of Hugo. The extended version of Hugo includes LibSass and a WebP image decoder/encoder.

1) Download the installer: mingw x86_64-posix-seh

2) Extract the 7z file, then move the mingw64\ directory to the root of your C:\ drive.


3) Update the PATH environment variable. Open a cmd window:

setx path "%PATH%;C:\mingw64\bin"

4) Verify that gcc is installed and in your PATH. Open a cmd window:


That should generate this error:

gcc: fatal error: no input files
compilation terminated.

5) Now compile the extended version of Hugo. Change to the directory containing the Hugo codebase, then:

go install -tags extended

Be patient; it might take a while.

6) Verify the build.

hugo version

This should produce something like:

hugo v0.89.0-DEV+extended windows/amd64 BuildDate=unknown

This worked - thank you!
I did have GCC installed but incorrectly by the looks of things, and I guess Go wasn’t finding it.
So the install command succeeds and hugo version returns this:

Hugo Static Site Generator v0.56.3/extended windows/amd64 BuildDate: unknown

The version’s a long way behind yours but hopefully not unexpected (remember I’m following the steps here: so am in a fork of master (currently unchanged).)

No doubt I’ll have more questions - need to get the tests running and passing now - but will start a new thread for anything arising from that.

Thanks again - everyone - for the input.

Upgrade your source to head before spending time on anything else.


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.