all: drop support for Go 1.15.x (#265)

This mainly cleans up the few bits of code where we explicitly kept
support for Go 1.15.x. With v0.1.0 released, we can drop support now,
since the next v0.2.0 release will only support Go 1.16.x.

Also updates all modules, including test ones, to 'go 1.16'.

Note that the TOOLEXEC_IMPORTPATH refactor is not done here, despite all
the TODOs about doing so when we drop 1.15 support. This is because that
refactor needs to be done carefully and might have side effects, so it's
best to keep it to a separate commit.

Finally, update the deps.
pull/266/head
Daniel Martí 4 years ago committed by GitHub
parent 1fcf50bbdd
commit ff0bea73b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,7 +10,7 @@ jobs:
test: test:
strategy: strategy:
matrix: matrix:
go-version: [1.15.x, 1.16.x] go-version: [1.16.x]
platform: [ubuntu-latest, macos-latest, windows-latest] platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
steps: steps:

@ -2,7 +2,7 @@
GO111MODULE=on go get mvdan.cc/garble GO111MODULE=on go get mvdan.cc/garble
Obfuscate Go code by wrapping the Go toolchain. Requires Go 1.15 or later. Obfuscate Go code by wrapping the Go toolchain. Requires Go 1.16 or later.
garble build [build flags] [packages] garble build [build flags] [packages]
@ -41,12 +41,12 @@ what packages to obfuscate, set `GOPRIVATE`, documented at `go help private`.
Note that commands like `garble build` will use the `go` version found in your Note that commands like `garble build` will use the `go` version found in your
`$PATH`. To use different versions of Go, you can `$PATH`. To use different versions of Go, you can
[install them](https://golang.org/doc/manage-install#installing-multiple) [install them](https://golang.org/doc/manage-install#installing-multiple)
and set up `$PATH` with them. For example, for Go 1.15.8: and set up `$PATH` with them. For example, for Go 1.16.1:
```sh ```sh
$ go get golang.org/dl/go1.15.8 $ go get golang.org/dl/go1.16.1
$ go1.15.8 download $ go1.16.1 download
$ PATH=$(go1.15.8 env GOROOT)/bin:${PATH} garble build $ PATH=$(go1.16.1 env GOROOT)/bin:${PATH} garble build
``` ```
You can also declare a function to make multiple uses simpler: You can also declare a function to make multiple uses simpler:
@ -58,7 +58,7 @@ $ withgo() {
PATH=$(${gocmd} env GOROOT)/bin:${PATH} "$@" PATH=$(${gocmd} env GOROOT)/bin:${PATH} "$@"
} }
$ withgo 1.15.8 garble build $ withgo 1.16.1 garble build
``` ```
### Caveats ### Caveats

@ -1,10 +1,10 @@
module mvdan.cc/garble module mvdan.cc/garble
go 1.15 go 1.16
require ( require (
github.com/google/go-cmp v0.5.4 github.com/google/go-cmp v0.5.5
github.com/rogpeppe/go-internal v1.7.1-0.20210131190821-dc4b49510d96 github.com/rogpeppe/go-internal v1.7.1-0.20210131190821-dc4b49510d96
golang.org/x/mod v0.4.1 golang.org/x/mod v0.4.1
golang.org/x/tools v0.0.0-20210115202250-e0d201561e39 golang.org/x/tools v0.1.1-0.20210304221016-50ca8d007de9
) )

@ -1,5 +1,5 @@
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@ -11,7 +11,6 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY= golang.org/x/mod v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@ -22,12 +21,13 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20210115202250-e0d201561e39 h1:BTs2GMGSMWpgtCpv1CE7vkJTv7XcHdcLLnAMu7UbgTY= golang.org/x/tools v0.1.1-0.20210304221016-50ca8d007de9 h1:lQ9QDTM4SHDP/S/bmj2wjNMQ93AvRYf7kuoqr2MDxmc=
golang.org/x/tools v0.0.0-20210115202250-e0d201561e39/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.1-0.20210304221016-50ca8d007de9/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

@ -166,13 +166,13 @@ var errJustExit = errors.New("")
func goVersionOK() bool { func goVersionOK() bool {
const ( const (
minGoVersion = "v1.15.0" minGoVersion = "v1.16.0"
suggestedGoVersion = "1.16.x" suggestedGoVersion = "1.16.x"
gitTimeFormat = "Mon Jan 2 15:04:05 2006 -0700" gitTimeFormat = "Mon Jan 2 15:04:05 2006 -0700"
) )
// Go 1.15 was released on August 11th, 2020. // Go 1.16 was released on Febuary 16th, 2021.
minGoVersionDate := time.Date(2020, 8, 11, 0, 0, 0, 0, time.UTC) minGoVersionDate := time.Date(2021, 2, 16, 0, 0, 0, 0, time.UTC)
out, err := exec.Command("go", "version").CombinedOutput() out, err := exec.Command("go", "version").CombinedOutput()
rawVersion := strings.TrimSpace(string(out)) rawVersion := strings.TrimSpace(string(out))
@ -811,21 +811,13 @@ var runtimeRelated = map[string]bool{
"vendor/golang.org/x/net/dns/dnsmessage": true, "vendor/golang.org/x/net/dns/dnsmessage": true,
"vendor/golang.org/x/net/route": true, "vendor/golang.org/x/net/route": true,
// These packages were moved in Go 1.16, but 1.15's runtime still
// linknames to them.
"io/ioutil": true,
"path/filepath": true,
// Go 1.15's "net" package depends on "math/rand", but 1.16's does not.
// Keep it here to support 1.15.
"math/rand": true,
// These packages call pure Go functions from assembly functions. // These packages call pure Go functions from assembly functions.
// We obfuscate the pure Go function name, breaking the assembly. // We obfuscate the pure Go function name, breaking the assembly.
// We do not deal with that edge case just yet, so for now, // We do not deal with that edge case just yet, so for now,
// never obfuscate these packages. // never obfuscate these packages.
// TODO: remove once we fix issue 261. // TODO: remove once we fix issue 261.
"math/big": true, "math/big": true,
"math/rand": true,
"crypto/sha512": true, "crypto/sha512": true,
"crypto": true, "crypto": true,
} }

@ -60,7 +60,6 @@ func TestScripts(t *testing.T) {
env.Vars = append(env.Vars, env.Vars = append(env.Vars,
"GOPROXY="+proxyURL, "GOPROXY="+proxyURL,
"GONOSUMDB=*", "GONOSUMDB=*",
"GOFLAGS=-mod=readonly", // TODO(mvdan): remove once we switch to Go 1.16
"gofullversion="+runtime.Version(), "gofullversion="+runtime.Version(),
) )

@ -123,7 +123,6 @@ func stripRuntime(filename string, file *ast.File) {
case "runtime1.go": case "runtime1.go":
// On Go 1.16.x, the code above results in runtime1.go having an // On Go 1.16.x, the code above results in runtime1.go having an
// unused import. Mark it as used via "var _ = pkg.Func". // unused import. Mark it as used via "var _ = pkg.Func".
// Note that the file in Go 1.15.x does not import bytealg.
// If this is a recurring problem, we could go for a more // If this is a recurring problem, we could go for a more
// generic solution like x/tools/imports. // generic solution like x/tools/imports.
for _, imp := range file.Imports { for _, imp := range file.Imports {

@ -218,15 +218,7 @@ func setListedPackages(patterns []string) error {
return err return err
} }
if pkg.Export != "" { if pkg.Export != "" {
buildID := pkg.BuildID actionID := decodeHash(splitActionID(pkg.BuildID))
if buildID == "" {
// go list only includes BuildID in 1.16+
buildID, err = buildidOf(pkg.Export)
if err != nil {
panic(err) // shouldn't happen
}
}
actionID := decodeHash(splitActionID(buildID))
h := sha256.New() h := sha256.New()
h.Write(actionID) h.Write(actionID)
h.Write(cache.BinaryContentID) h.Write(cache.BinaryContentID)

@ -19,7 +19,7 @@ cmp stderr main.stderr
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
-- main.go -- -- main.go --
package main package main

@ -58,7 +58,7 @@ binsubstr main$exe 'main.go' 'globalVar' 'globalFunc' $gofullversion
-- go.mod -- -- go.mod --
module test/mainfoo module test/mainfoo
go 1.15 go 1.16
-- main.go -- -- main.go --
package main package main

@ -19,7 +19,7 @@ cmp stderr main.stderr
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
-- main.go -- -- main.go --
package main package main

@ -18,7 +18,7 @@ stderr 'test/main' # we force rebuilds with -debugdir
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
-- main.go -- -- main.go --
package main package main

@ -26,7 +26,7 @@ garble build -o=out ./stdimporter
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
-- standalone/main.go -- -- standalone/main.go --
package main package main

@ -20,13 +20,12 @@ env GO_VERSION='go version devel +afb5fca Sun Sep 99 99:99:99 9999 +0000 linux/a
stderr 'Can''t recognize devel build timestamp: parsing time' stderr 'Can''t recognize devel build timestamp: parsing time'
# We should error on a devel version that's too old. # We should error on a devel version that's too old.
# We support Go 1.15 and later, released on August 11th, 2020.
env GO_VERSION='go version devel +afb5fca Sun Aug 07 00:00:00 2020 +0000 linux/amd64' env GO_VERSION='go version devel +afb5fca Sun Aug 07 00:00:00 2020 +0000 linux/amd64'
! garble build ! garble build
stderr 'Go version.*Aug 07.*too old; please upgrade to Go 1.16.x or a newer devel version' stderr 'Go version.*Aug 07.*too old; please upgrade to Go 1.16.x or a newer devel version'
# A recent enough devel timestamp should be fine. # A future devel timestamp should be fine.
env GO_VERSION='go version devel +afb5fca Sun Sep 13 07:54:42 2020 +0000 linux/amd64' env GO_VERSION='go version devel +afb5fca Sun Sep 13 07:54:42 2021 +0000 linux/amd64'
! garble build ! garble build
stderr 'mocking the real build' stderr 'mocking the real build'
@ -36,15 +35,15 @@ env GO_VERSION='go version go1.14 windows/amd64'
stderr 'Go version.*go1.14.*too old; please upgrade to Go 1.16.x' stderr 'Go version.*go1.14.*too old; please upgrade to Go 1.16.x'
! stderr 'or a newer devel version' ! stderr 'or a newer devel version'
# We should accept a supported stable version. # We should accept a future stable version.
env GO_VERSION='go version go1.15.2 windows/amd64' env GO_VERSION='go version go1.16.2 windows/amd64'
! garble build ! garble build
stderr 'mocking the real build' stderr 'mocking the real build'
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
-- main.go -- -- main.go --
package main package main

@ -9,7 +9,7 @@ cmp stderr main.stderr
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
-- main.go -- -- main.go --
package main package main

@ -45,7 +45,7 @@ cmp stdout main.stdout
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
require ( require (
rsc.io/quote v1.5.2 rsc.io/quote v1.5.2

@ -13,7 +13,7 @@ cmp stderr main.stderr
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
-- main.go -- -- main.go --
package main package main

@ -23,7 +23,7 @@ binsubstr main$exe 'unexportedVersion'
-- go.mod -- -- go.mod --
module domain.test/main module domain.test/main
go 1.15 go 1.16
-- main.go -- -- main.go --
package main package main

@ -15,7 +15,7 @@ cmp stderr main.stderr
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
-- main.go -- -- main.go --
package main package main

@ -55,7 +55,7 @@ grep '^\s+type \w+ func\(byte\) \w+$' .obf-src/main/extra_literals.go
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
-- main.go -- -- main.go --
package main package main

@ -15,7 +15,7 @@ binsubstr main$exe '(devel)'
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
-- main.go -- -- main.go --
package main package main

@ -29,7 +29,7 @@ cmp stderr main.stderr
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
-- plugin/main.go -- -- plugin/main.go --
package main package main

@ -17,7 +17,7 @@ stdout 'varLines is sorted'
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
-- main.go -- -- main.go --
package main package main

@ -30,7 +30,7 @@ cmp stderr reverse.stdout
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
-- main.go -- -- main.go --
package main package main

@ -40,7 +40,7 @@ stderr .
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
-- main.go -- -- main.go --
package main package main

@ -13,13 +13,13 @@ go build
exec ./main$exe exec ./main$exe
cmp stderr main.stderr cmp stderr main.stderr
binsubstr main$exe 'globalVar' # 'globalType' only matches on go < 1.15 binsubstr main$exe 'globalVar' # 'globalType' matches on some, but not all, platforms
! binsubstr main$exe 'localName' 'globalConst' 'remoteIntReturn' 'intReturn' ! binsubstr main$exe 'localName' 'globalConst' 'remoteIntReturn' 'intReturn'
-- extra/go.mod -- -- extra/go.mod --
module private.source/extra module private.source/extra
go 1.15 go 1.16
-- extra/extra.go -- -- extra/extra.go --
package extra package extra
@ -29,7 +29,7 @@ func Func() string {
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
// We include an extra module to obfuscate, included in the same original source // We include an extra module to obfuscate, included in the same original source
// code via a replace directive. // code via a replace directive.

@ -22,7 +22,7 @@ stdout 'PASS.*TestFoo'
-- go.mod -- -- go.mod --
module test/bar module test/bar
go 1.15 go 1.16
-- bar.go -- -- bar.go --
package bar package bar

@ -27,7 +27,7 @@ stderr 'panic: oh noes'
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.15 go 1.16
-- main.go -- -- main.go --
package main package main

Loading…
Cancel
Save