You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
In the worst case scenario, when GOPRIVATE isn't set at all, we would run these three commands: * "go env GOPRIVATE", to fetch GOPRIVATE itself * "go list -m", for GOPRIVATE's fallback * "go version", to check the version of Go being used Now that we support Go 1.16 and later, all these three can be obtained via "go env -json": $ go env -json GOPRIVATE GOMOD GOVERSION { "GOMOD": "/home/mvdan/src/garble/go.mod", "GOPRIVATE": "", "GOVERSION": "go1.16.3" } Note that we don't get the module path directly, but we can use the x/mod/modfile Go API to parse it from the GOMOD file cheaply. Notably, this also simplifies our Go version checking logic, as now we get just the version string without the "go version" prefix and "GOOS/GOARCH" suffix we don't care about. This makes our code a bit more maintainable and robust. When running a short incremental build, we can also see a small speed-up, as saving two "go" invocations can save a few milliseconds: name old time/op new time/op delta Build/Cache-8 168ms ± 0% 166ms ± 1% -1.26% (p=0.009 n=6+6) name old bin-B new bin-B delta Build/Cache-8 6.36M ± 0% 6.36M ± 0% +0.12% (p=0.002 n=6+6) name old sys-time/op new sys-time/op delta Build/Cache-8 222ms ± 2% 219ms ± 3% ~ (p=0.589 n=6+6) name old user-time/op new user-time/op delta Build/Cache-8 857ms ± 1% 846ms ± 1% -1.31% (p=0.041 n=6+6) |
4 years ago | |
---|---|---|
.. | ||
asm.txt | 4 years ago | |
basic.txt | 4 years ago | |
cgo.txt | 4 years ago | |
debugdir.txt | 4 years ago | |
embed.txt | 4 years ago | |
goprivate.txt | 4 years ago | |
goversion.txt | 4 years ago | |
help.txt | 4 years ago | |
implement.txt | 4 years ago | |
imports.txt | 4 years ago | |
init.txt | 4 years ago | |
ldflags.txt | 4 years ago | |
linkname.txt | 4 years ago | |
literals.txt | 4 years ago | |
modinfo.txt | 4 years ago | |
plugin.txt | 4 years ago | |
position.txt | 4 years ago | |
reverse.txt | 4 years ago | |
seed.txt | 4 years ago | |
syntax.txt | 4 years ago | |
test.txt | 4 years ago | |
tiny.txt | 4 years ago |