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.
garble/testdata/scripts
Daniel Martí 3afc993266 use "go env -json" to collect env info all at once
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 obfuscate asm function names as well (#273) 4 years ago
basic.txt testdata: reduce the cost of short tests 4 years ago
cgo.txt all: drop support for Go 1.15.x (#265) 4 years ago
debugdir.txt refactor "current package" with TOOLEXEC_IMPORTPATH (#266) 4 years ago
embed.txt don't obfuscate the "embed" import path 4 years ago
goprivate.txt obfuscate asm function names as well (#273) 4 years ago
goversion.txt use "go env -json" to collect env info all at once 4 years ago
help.txt make "help" refuse arguments for now 4 years ago
implement.txt all: drop support for Go 1.15.x (#265) 4 years ago
imports.txt all: drop support for Go 1.15.x (#265) 4 years ago
init.txt all: drop support for Go 1.15.x (#265) 4 years ago
ldflags.txt testdata: remove some unnecessary execs (#267) 4 years ago
linkname.txt fix a regression involving imported linkname funcs 4 years ago
literals.txt make -literals succeed on all of std 4 years ago
modinfo.txt testdata: remove some unnecessary execs (#267) 4 years ago
plugin.txt all: drop support for Go 1.15.x (#265) 4 years ago
position.txt improve "reverse" even further (#289) 4 years ago
reverse.txt testdata: reduce the cost of short tests 4 years ago
seed.txt make flags like -literals and GOPRIVATE affect hashing (#288) 4 years ago
syntax.txt all: drop support for Go 1.15.x (#265) 4 years ago
test.txt testdata: reduce the cost of short tests 4 years ago
tiny.txt use hashWith for obfuscation position information 4 years ago