Go modules

(Jakob Borg) #1

Syncthing is now a Go module, so dependencies are tracked in go.mod & go.sum and managed by the usual go get commands plus a few modules specific ones like go mod vendor. We still have the vendor dir for non-module builds (old style GOPATH). It’s not used for production builds or when you build in module mode, though.

You’ll be in “module mode” if you use Go 1.11 and set GO111MODULE=on or build outside of $GOPATH (~/go). This is how I roll nowadays.

The build server has an Athens module proxy on https://build.syncthing.net/athens. This is essentially just a caching proxy, meaning the build server will download a dependency only once and then hold on to it forever. Apart from being efficient this protects against dependencies disappearing or becoming unavailable.

(Simon) #2

Thanks! I just pulled and built and it just worked - that’s how I like it :slight_smile:

I’ll see another time whether updating a dependency goes equally effortlessly.

EDIT: When I wrote the above, I actually thought that I was on Go1.12 already, so I didn’t set the env var to activate modules o.O
However it still works after doing so.

(xor-gate) #3

Nice work @calmh, nice to see it moving forward!

(xor-gate) #4

I think it works with Go1.11 because the modules env var is set to auto if it detects go.mod. See https://github.com/golang/go/wiki/Modules#how-to-install-and-activate-module-support.