Skip to content

aarons-talks/2019-03-22-CodeMotion-Rome

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Building Hugo with Go Modules and Athens 🎉

Hey Gophers! We're gonna build Hugo with Go Modules and Athens. I gave this demo at CodeMotion Rome 2019 in the session titled "Using the Athens Proxy to Improve Your Golang Projects"

athens banner

Run The Demo

Below is how how to do the demo yourself. The instructions are for Linux/Mac OS X systems.

Check out Hugo Locally

You can do this anywhere on your system:

$ git clone https://github.com/gohugoio/hugo.git && cd hugo

Point to the Public Athens

This will make go talk to Athens for all its dependencies, not directly to the VCS:

$ export GOPROXY=https://athens.azurefd.net

Note: the proxy at this URL is experimental and should not be used in production settings

Clear Local Module Cache

This will force go to ask Athens for all the dependencies. You have to run this with sudo because the Go toolchain restricts modules to read-only. It tries to keep dependencies immutable too, just like Athens does! 😄.

$ sudo rm -r $GOPATH/pkg/mod

Build the Binary!

No need to change your familiar tools to do this:

$ go build .

Test Things Out

Just to make sure things worked properly:

$ ls -al ./hugo
$ ./hugo version

Where to Go from Here

You can use Athens for any project that uses Go modules. Just set GOPROXY to https://athens.azurefd.net in your environment.

But remember, that URL is an experimental Athens server for now. Please do not rely on it for production code.

Another Adventure... Run Your Own Athens!

If you'd rather not rely on the public Athens (it is experimental after all!), then run your own! The easiest way to do that -- and the way I recommend -- is using Docker. Run this to start up Athens:

$ docker run -p 3000:3000 -e GO_ENV=development gomods/athens:v0.3.1

And then to set your environment variable to point to the local server:

$ export GOPROXY=http://localhost:3000

From here, go back and clear your cache and build Hugo again. Magic!!!

Finally

If you want to learn more, check out docs.gomods.io! And we'd love for you to get involved! Here are some ways to do so:

Keep on rockin', Gophers!

athens gopher

About

Sample Code from my CodeMotion Rome Talk

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages