Building Hugo DEV from source in Go 1.16

I recently migrated from Linux to macOS and with go1.16.2 installed I noticed the following difference from my previous setup:

In go1.15.3 the command go get -u -v github.com/gohugoio/hugo compiled the latest unreleased Hugo DEV version when executed from within the Go default packages directory.

But with go1.16.2 the same command under the same folder compiled the latest Hugo release and not the DEV version.

After a bit of tinkering, I found out that executing the command from within my local Hugo fork that resides outside the Go packages directory compiles the DEV version.

P.S. Thanks @bep for clearing this up.

3 Likes

On my Macbook I have a ~/go folder outside my usual hugo git.

And I compile the latest DEV code with this:

git pull https://github.com/gohugoio/hugo.git
go install
1 Like

Yes. Same same, yet slightly different. Thanks for sharing.

I’m pretty sure the difference you see is because of the Go version and not the OS used.

1 Like

Yes you are right.

I just checked on Linux I had go1.15.3 linux/amd after updating to go1.16.2 I am seeing the same behaviour as on macOS, with one exception: the previous compiled Hugo Linux binary needs to be deleted because otherwise the version displayed with Hugo version will remain the same as before.

Thanks for the heads up! I have amended the topic title and the first post.

So, a nice new thing in Go 1.16 is that you can now do:

go get -u -v github.com/gohugoio/hugo@v0.76.0

Etc.

1 Like

How can I compile Hugo for the darwin arm64 architecture?

Is there a tag I can pass?

I tried: go install --tags extended arm64
but I got
package arm64 is not in GOROOT (/usr/local/go/src/arm64)

Go version:
go version go1.16.5 darwin/arm64

Hugo version compiled from source with go install --tags extended
hugo v0.84.0-DEV+extended darwin/amd64 BuildDate=unknown

It seems that with the above command the amd64 architecture is used.

Set the GOARCH env var: dockerfiles/Dockerfile at master · bep/dockerfiles · GitHub

Note that the above is used in a Linux Docker image – on MacOS, GOARCH alone should do the trick.

1 Like

Thank you.

It seems that the compiled binary is arm64 when I test it from within the fork’s folder.

./hugo version
hugo v0.84.0-DEV+extended darwin/arm64 BuildDate=unknown

But once I move the binary under the go/bin/ that is under my $PATH.
I am getting again the amd64 architecture displayed:

hugo version
hugo v0.84.0-DEV+extended darwin/amd64 BuildDate=unknown

It seems that this is a cache issue. Not quite sure how to clear the cache of the Hugo binary on macOS.