Add (experimental) support for offloading dependency management to Go using
go mod download.
Using GH_TUPLE for managing Go port dependencies has several issues:
- Go dependencies are modules, not repositories that GH_TUPLE was designed to work with. A single repo can often contain multiple independently versioned Go modules and this arrangement is hard to work with using GH machinery.
- Because of the above, modules2tuple often has difficulties handling corner cases. This makes porting of some Go software unnecessarily difficult.
- Not all dependencies have Github mirrors.
- Port maintainers sometimes forget to update {GH,GL}_TUPLE dependencies. The port may still build but the resulting binary is not what upstream tested or released.
- Due to Go getting stricter about validating vendored deps in recent versions, we have to use patched Go version to relax these restrictions [1].
On the other hand, Go already know how to download [2] and verify integrity
[3] of all dependencies required for building a Go port. None of the drawbacks
listed above apply and required configuration in some cases can be reduced to
a single variable GO_MODULE.
How to switch:
- Make sure that the port uses Go modules (USES=go:modules)
- Add GO_MODULE=... variable and set it to the module name as shown in the module directive in upstream's go.mod.
- Remove USE_GITHUB/USE_GITLAB and related GH/GL variables (GH_ACCOUNT, GH_PROJECT, GH_TUPLE etc).
- make makesum to update distinfo and populate module cache.
The only upstream used in this mode is an instance of Go module proxy
(https://proxy.golang.org by default). This can be changed by setting GO_GOPROXY
variable.
Example:
- Current devel/goswagger: https://gist.github.com/dmgk/47af523fee37fb524fd87b5ec718844a
- After conversion: https://gist.github.com/dmgk/fb9e314c6229c09e07d0ed5ab5bf55dd
[1] https://github.com/golang/go/issues/37948
[2] https://golang.org/ref/mod#go-mod-download
[3] https://www.goproxy.io/docs/GOSUMDB-env.html