My golang modules live in Athens

Historical place with great weather and fantastic cuisine, no wonder…
thumbnail

So I’ve been on the fence with the vendor directory.

On one hand, it’s great to have the modules in the project because it speeds up the build and serves as a safe storage.

On the other hand, it does increase the churn in the repository and creates a lot of duplication on disk because many projects often contain the same dependencies.

Since I do like holding on to my dependencies and go mod works great for me, I’ve decided to try out The Athens. I’s awesome.

§What is it

It is a self-hosted golang module mirror service. Unlike the public proxy.golang.org, it can cache private modules so no more GOPRIVATE, yay!

Athens offers a selection of storage back ends: local disk, S3, Minio, GCS and the like. One instance can be pointed at another with upstream services. The documentation is very approachable.

§How I run it

KISS, Docker service backed with the disk type storage. Basically like this:

1
2
3
4
5
6
7
mkdir -p /var/lib/gomod
docker run --rm \
    -p 15001:3000 \
    -v /var/lib/gomod:/gomod \
    -e ATHENS_STORAGE_TYPE=disk \
    -e ATHENS_DISK_STORAGE_ROOT=/gomod \
    -d gomods/athens:latest

I’ve exported the GOPROXY=http://localhost:15001 in my Bash profile so tools use it automatically. I have a dedicated git repository where I sync my local modules to a couple of time a day.

Long term, maybe something like the S3 storage would be a better option but I’m not sure how expensive it can get.