Gentoo Archives: gentoo-dev

From: William Hubbs <williamh@g.o>
To: gentoo development <gentoo-dev@l.g.o>
Subject: [gentoo-dev] rfc: go 1.13 and go modules
Date: Mon, 09 Sep 2019 17:34:27
Message-Id: 20190909173418.GA30003@whubbs1.dev.av1.gaikai.org
1 All,
2
3 First off, everything I'm saying here is definitely open to discussion;
4 they are issues I have found with go 1.13.
5
6 with Go 1.13, go modules are the default way to build software written
7 in Go. If upstream has a go.mod file in their distribution, this
8 version of Go will assume that they are using modules unless modules are
9 disabled explicitly by setting the GO111MODULE environment variable to
10 off[1], so if your upstream does not have go.mod, it will work as
11 before.
12
13 This is not turned off globally because upstream is encouraging projects
14 to move to using modules [3] [4].
15
16 So far, here is what I've found if an upstream uses go modules.
17
18 dev-vcs/hub vendors the modules into their upstream repository using
19 "go mod vendor" and keeps go.mod and go.sum up to date. The build commands in
20 their makefiles use the "-mod vendor" switch as well. In this case,
21 the ebuild author doesn't have to do anything about the modules.
22
23 If the modules are not vendored (there is no vendor directory in the
24 upstream repository), the only option I've tried so far is to run "go
25 mod vendor" in the root of the upstream repository then tar up the
26 vendor directory and mirror it on our infrastructure. In that scenario,
27 you need to add "-mod vendor" to any "go build" commands upstream uses
28 and have a src_prepare function that moves the vendor directory into the
29 appropriate place. See www-apps/trickster (not trickster-bin). This also
30 seems to avoid the module mirror database.
31
32 There is another option I want to try which is adding "go mod vendor" to
33 src_unpack for go packages.
34
35 Thoughts?
36
37 Thanks,
38
39 William
40
41 [1] https://golang.org/cmd/go/#hdr-Module_support
42 [2] https://golang.org/doc/go1.13#modules
43 [3] https://blog.golang.org/migrating-to-go-modules
44 [4] https://blog.golang.org/using-go-modules

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-dev] rfc: go 1.13 and go modules Zac Medico <zmedico@g.o>
Re: [gentoo-dev] rfc: go 1.13 and go modules Ulrich Mueller <ulm@g.o>
Re: [gentoo-dev] rfc: go 1.13 and go modules Kent Fredric <kentnl@g.o>