diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6b59e6e..56ffc35 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: test: strategy: matrix: - go-version: [1.17.x, 1.18.x] + go-version: [1.18.x] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: @@ -44,8 +44,8 @@ jobs: run: diff <(echo -n) <(gofmt -d .) - if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.18.x' run: go vet ./... - # TODO: bump to Go 1.18 once staticcheck supports it - - if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.17.x' + # TODO: reenable once staticcheck supports Go 1.18 + - if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.18.x' && false uses: dominikh/staticcheck-action@v1 with: version: "2021.1.2" diff --git a/README.md b/README.md index b3a5458..04e87b4 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ go install mvdan.cc/garble@latest -Obfuscate Go code by wrapping the Go toolchain. Requires Go 1.17 or later. +Obfuscate Go code by wrapping the Go toolchain. Requires Go 1.18 or later. garble build [build flags] [packages] diff --git a/go.mod b/go.mod index eab3ab5..e1fbeb6 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module mvdan.cc/garble -go 1.17 +go 1.18 require ( github.com/frankban/quicktest v1.14.2 diff --git a/go.sum b/go.sum index 164c876..68f903e 100644 --- a/go.sum +++ b/go.sum @@ -15,33 +15,11 @@ github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsK github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -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.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -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.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= -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-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/main.go b/main.go index d7f3cec..5033f3f 100644 --- a/main.go +++ b/main.go @@ -195,8 +195,9 @@ func (w *uniqueLineWriter) Write(p []byte) (n int, err error) { } // debugf is like log.Printf, but it is a no-op by default. -// TODO(mvdan): remove once we use 1.18: https://github.com/golang/go/issues/47164 -func debugf(format string, args ...interface{}) { +// TODO(mvdan): use our own debug logger instead of hijacking the global one, +// and drop the "flagDebug" no-op check now that we require Go 1.18 or later. +func debugf(format string, args ...any) { if !flagDebug { return } @@ -263,8 +264,8 @@ var toolchainVersionSemver string func goVersionOK() bool { const ( - minGoVersionSemver = "v1.17.0" - suggestedGoVersion = "1.17.x" + minGoVersionSemver = "v1.18.0" + suggestedGoVersion = "1.18.x" ) // rxVersion looks for a version like "go1.2" or "go1.2.3" @@ -497,10 +498,7 @@ This command wraps "go %s". Below is its help: goArgs := []string{ command, "-trimpath", - } - if semver.Compare(toolchainVersionSemver, "v1.18.0") >= 0 { - // TODO: remove the conditional once we drop support for 1.17 - goArgs = append(goArgs, "-buildvcs=false") + "-buildvcs=false", } // Pass the garble flags down to each toolexec invocation. diff --git a/position.go b/position.go index 5cbd28b..c48e4c9 100644 --- a/position.go +++ b/position.go @@ -15,6 +15,8 @@ import ( ) func isDirective(text string) bool { + // TODO: can we remove the check for "// +build" now that we require Go 1.18 + // or later? we should update the tests too. return strings.HasPrefix(text, "//go:") || strings.HasPrefix(text, "// +build") } diff --git a/runtime_strip.go b/runtime_strip.go index e9a3215..66b02cb 100644 --- a/runtime_strip.go +++ b/runtime_strip.go @@ -128,8 +128,7 @@ func stripRuntime(filename string, file *ast.File) { switch filename { case "print.go": // was used in hexdumpWords - x.Specs = removeImport(`"runtime/internal/sys"`, x.Specs) // Before Go 1.18. - x.Specs = removeImport(`"internal/goarch"`, x.Specs) // Go 1.18. + x.Specs = removeImport(`"internal/goarch"`, x.Specs) case "traceback.go": // was used in traceback1 x.Specs = removeImport(`"runtime/internal/atomic"`, x.Specs) diff --git a/shared.go b/shared.go index c770f27..d3c3ab5 100644 --- a/shared.go +++ b/shared.go @@ -113,7 +113,7 @@ func writeFileExclusive(name string, data []byte) error { return err } -func writeGobExclusive(name string, val interface{}) error { +func writeGobExclusive(name string, val any) error { f, err := createExclusive(name) if err != nil { return err diff --git a/testdata/scripts/asm.txt b/testdata/scripts/asm.txt index 2e45dff..2768ec7 100644 --- a/testdata/scripts/asm.txt +++ b/testdata/scripts/asm.txt @@ -23,7 +23,7 @@ binsubstr main$exe 'privateAdd' 'PublicAdd' -- go.mod -- module test/main -go 1.17 +go 1.18 -- main.go -- package main diff --git a/testdata/scripts/basic.txt b/testdata/scripts/basic.txt index b291be7..cec5446 100644 --- a/testdata/scripts/basic.txt +++ b/testdata/scripts/basic.txt @@ -58,7 +58,7 @@ binsubstr main$exe 'garble_main.go' 'globalVar' 'globalFunc' $gofullversion -- go.mod -- module test/mainfoo -go 1.17 +go 1.18 -- garble_main.go -- package main diff --git a/testdata/scripts/cgo.txt b/testdata/scripts/cgo.txt index 58d334d..9cf290e 100644 --- a/testdata/scripts/cgo.txt +++ b/testdata/scripts/cgo.txt @@ -27,7 +27,7 @@ binsubstr main$exe 'privateAdd' -- go.mod -- module test/main -go 1.17 +go 1.18 -- main.go -- package main diff --git a/testdata/scripts/crossbuild.txt b/testdata/scripts/crossbuild.txt index b681856..27165cd 100644 --- a/testdata/scripts/crossbuild.txt +++ b/testdata/scripts/crossbuild.txt @@ -15,7 +15,7 @@ garble build -- go.mod -- module test/main -go 1.17 +go 1.18 -- main.go -- package main diff --git a/testdata/scripts/debugdir.txt b/testdata/scripts/debugdir.txt index 75e52f1..464178b 100644 --- a/testdata/scripts/debugdir.txt +++ b/testdata/scripts/debugdir.txt @@ -18,7 +18,7 @@ stderr 'test/main' # we force rebuilds with -debugdir -- go.mod -- module test/main -go 1.17 +go 1.18 -- main.go -- package main diff --git a/testdata/scripts/embed.txt b/testdata/scripts/embed.txt index 71450a3..962b4f5 100644 --- a/testdata/scripts/embed.txt +++ b/testdata/scripts/embed.txt @@ -14,7 +14,7 @@ cmp stdout main.stdout -- go.mod -- module test/main -go 1.17 +go 1.18 -- main.go -- package main diff --git a/testdata/scripts/gogarble.txt b/testdata/scripts/gogarble.txt index 26bee34..1ab96ab 100644 --- a/testdata/scripts/gogarble.txt +++ b/testdata/scripts/gogarble.txt @@ -50,7 +50,7 @@ bincmp out_rebuild out -- go.mod -- module test/main -go 1.17 +go 1.18 -- standalone/main.go -- package main diff --git a/testdata/scripts/goversion.txt b/testdata/scripts/goversion.txt index b60e0d3..9f3b764 100644 --- a/testdata/scripts/goversion.txt +++ b/testdata/scripts/goversion.txt @@ -7,18 +7,18 @@ env PATH=${WORK}/.bin${:}${PATH} # An empty go version. env TOOLCHAIN_GOVERSION='' ! garble build -stderr 'Go version is too old; please upgrade to Go 1\.17\.x or a newer devel version' +stderr 'Go version is too old; please upgrade to Go 1\.18\.x or a newer devel version' # We should error on a devel version that's too old. # Note that they lacked the "goN.M-" prefix. env TOOLCHAIN_GOVERSION='devel +afb5fca Sun Aug 07 00:00:00 2020 +0000' ! garble build -stderr 'Go version is too old; please upgrade to Go 1\.17\.x or a newer devel version' +stderr 'Go version is too old; please upgrade to Go 1\.18\.x or a newer devel version' # Another form of old version; with an old "goN.M-" prefix. env TOOLCHAIN_GOVERSION='devel go1.15-afb5fca Sun Aug 07 00:00:00 2020 +0000' ! garble build -stderr 'Go version "devel go1\.15-.*2020.*" is too old; please upgrade to Go 1\.17\.x' +stderr 'Go version "devel go1\.15-.*2020.*" is too old; please upgrade to Go 1\.18\.x' # A current devel version should be fine. # Note that we don't look at devel version timestamps. @@ -30,7 +30,7 @@ stderr 'mocking the real build' # We should error on a stable version that's too old. env TOOLCHAIN_GOVERSION='go1.14' ! garble build -stderr 'Go version "go1\.14" is too old; please upgrade to Go 1\.17\.x' +stderr 'Go version "go1\.14" is too old; please upgrade to Go 1\.18\.x' ! stderr 'or a newer devel version' # We should accept a future stable version. @@ -46,8 +46,8 @@ env TOOLCHAIN_GOVERSION='devel go1.18-somecustomversion' stderr 'mocking the real build' # The current toolchain may be older than the one that built garble. -env GARBLE_TEST_GOVERSION='go1.18' -env TOOLCHAIN_GOVERSION='go1.17.3' +env GARBLE_TEST_GOVERSION='go1.19' +env TOOLCHAIN_GOVERSION='go1.18.3' ! garble build stderr 'mocking the real build' @@ -58,10 +58,10 @@ env TOOLCHAIN_GOVERSION='devel go1.19-6673d5d701 Sun Mar 20 16:05:03 2022 +0000' stderr 'mocking the real build' # The current toolchain must not be newer than the one that built garble. -env GARBLE_TEST_GOVERSION='go1.17' -env TOOLCHAIN_GOVERSION='go1.18.1' +env GARBLE_TEST_GOVERSION='go1.18' +env TOOLCHAIN_GOVERSION='go1.19.1' ! garble build -stderr 'garble was built with "go1\.17" and is being used with "go1\.18\.1"; please rebuild garble with the newer version' +stderr 'garble was built with "go1\.18" and is being used with "go1\.19\.1"; please rebuild garble with the newer version' # We'll error even if the difference is a minor (bugfix) level. # In practice it probably wouldn't matter, but in theory it could still lead to tricky bugs. @@ -73,14 +73,14 @@ stderr 'garble was built with "go1\.18\.11" and is being used with "go1\.18\.14" # If garble builds itself and is then used, it won't know what version built it. # As a fallback, we drop the comparison against the toolchain's version. env GARBLE_TEST_GOVERSION='bogus version' -env TOOLCHAIN_GOVERSION='go1.17.3' +env TOOLCHAIN_GOVERSION='go1.18.3' ! garble build stderr 'mocking the real build' -- go.mod -- module test/main -go 1.17 +go 1.18 -- main.go -- package main diff --git a/testdata/scripts/implement.txt b/testdata/scripts/implement.txt index 45df43c..bc99902 100644 --- a/testdata/scripts/implement.txt +++ b/testdata/scripts/implement.txt @@ -16,7 +16,7 @@ cmp stdout main.stdout -- go.mod -- module test/main -go 1.17 +go 1.18 -- main.go -- package main @@ -91,7 +91,7 @@ type Struct2 struct { package lib3 type StructEmbed struct { - Baz interface{} + Baz any } -- main.stdout -- String method for foo diff --git a/testdata/scripts/imports.txt b/testdata/scripts/imports.txt index 246ef84..6f29a6e 100644 --- a/testdata/scripts/imports.txt +++ b/testdata/scripts/imports.txt @@ -45,7 +45,7 @@ cmp stdout main.stdout -- go.mod -- module test/main -go 1.17 +go 1.18 require ( gopkg.in/garbletest.v2 v2.999.0 @@ -93,7 +93,7 @@ func main() { garbletest.Test() } -func printfWithoutPackage(format string, v interface{}) { +func printfWithoutPackage(format string, v any) { fmt.Print(strings.Split(fmt.Sprintf(format, v), ".")[1]) } -- notag_fail.go -- diff --git a/testdata/scripts/init.txt b/testdata/scripts/init.txt index 1a15df7..0e7eda9 100644 --- a/testdata/scripts/init.txt +++ b/testdata/scripts/init.txt @@ -13,7 +13,7 @@ cmp stderr main.stderr -- go.mod -- module test/main -go 1.17 +go 1.18 -- main.go -- package main diff --git a/testdata/scripts/ldflags.txt b/testdata/scripts/ldflags.txt index 3b74286..3b717aa 100644 --- a/testdata/scripts/ldflags.txt +++ b/testdata/scripts/ldflags.txt @@ -31,7 +31,7 @@ binsubstr main$exe 'unexportedVersion' 'ExportedUnset' 'v1.22.33' 'garble_replac -- go.mod -- module domain.test/main -go 1.17 +go 1.18 -- main.go -- package main diff --git a/testdata/scripts/linkname.txt b/testdata/scripts/linkname.txt index a0b550f..cf5ec23 100644 --- a/testdata/scripts/linkname.txt +++ b/testdata/scripts/linkname.txt @@ -15,7 +15,7 @@ cmp stderr main.stderr -- go.mod -- module test/main -go 1.17 +go 1.18 replace big.chungus/meme => ./big.chungus/meme @@ -52,7 +52,7 @@ func byteIndex(s string, c byte) int // A linkname to an external non-obfuscated non-exported func. //go:linkname interfaceEqual os/exec.interfaceEqual -func interfaceEqual(a, b interface{}) bool +func interfaceEqual(a, b any) bool // A linkname to an external obfuscated func. //go:linkname obfuscatedFunc test/main/imported.ObfuscatedFuncImpl @@ -99,7 +99,7 @@ func ByteIndex(s string, c byte) int -- big.chungus/meme/go.mod -- module test/main -go 1.17 +go 1.18 -- big.chungus/meme/dante.go -- package meme diff --git a/testdata/scripts/literals.txt b/testdata/scripts/literals.txt index f069e00..064b2e8 100644 --- a/testdata/scripts/literals.txt +++ b/testdata/scripts/literals.txt @@ -57,7 +57,7 @@ garble -literals build std -- go.mod -- module test/main -go 1.17 +go 1.18 -- main.go -- package main diff --git a/testdata/scripts/modinfo.txt b/testdata/scripts/modinfo.txt index 781c6c0..70c5fc7 100644 --- a/testdata/scripts/modinfo.txt +++ b/testdata/scripts/modinfo.txt @@ -18,19 +18,18 @@ stdout -count=1 '^.+$' # expect just one line [short] stop # no need to verify this with -short go build -tags veryuniquebuildtag -[!go1.18] binsubstr main$exe '(devel)' -[go1.18] binsubstr main$exe '(devel)' 'veryuniquebuildtag' ${HEAD_COMMIT_SHA} +binsubstr main$exe '(devel)' 'veryuniquebuildtag' ${HEAD_COMMIT_SHA} go version -m main$exe stdout 'path\s*test/main' stdout 'mod\s*test/main\s*\(devel\)' -[go1.18] stdout 'build\s*-tags=veryuniquebuildtag' -[go1.18] stdout 'build\s*vcs.revision='${HEAD_COMMIT_SHA} +stdout 'build\s*-tags=veryuniquebuildtag' +stdout 'build\s*vcs.revision='${HEAD_COMMIT_SHA} -- go.mod -- module test/main -go 1.17 +go 1.18 -- main.go -- package main diff --git a/testdata/scripts/plugin.txt b/testdata/scripts/plugin.txt index c7bbdd2..567c294 100644 --- a/testdata/scripts/plugin.txt +++ b/testdata/scripts/plugin.txt @@ -29,7 +29,7 @@ cmp stderr main.stderr -- go.mod -- module test/main -go 1.17 +go 1.18 -- plugin/main.go -- package main diff --git a/testdata/scripts/position.txt b/testdata/scripts/position.txt index 492a86f..81d5a31 100644 --- a/testdata/scripts/position.txt +++ b/testdata/scripts/position.txt @@ -19,7 +19,7 @@ stdout 'varPositions is sorted' -- go.mod -- module test/main -go 1.17 +go 1.18 -- garble_main.go -- package main diff --git a/testdata/scripts/reflect.txt b/testdata/scripts/reflect.txt index 8763779..b49f72e 100644 --- a/testdata/scripts/reflect.txt +++ b/testdata/scripts/reflect.txt @@ -17,7 +17,7 @@ cmp stdout main.stdout -- go.mod -- module test/main -go 1.17 +go 1.18 -- garble_main.go -- package main @@ -111,7 +111,7 @@ type EmbeddingIndirect struct { importedpkg.AliasIndirectNamedWithReflect } -func printfWithoutPackage(format string, v interface{}) { +func printfWithoutPackage(format string, v any) { s := fmt.Sprintf(format, v) if i := strings.IndexByte(s, '.'); i > 0 { s = s[i+1:] @@ -135,7 +135,7 @@ type IndirectReflection struct { ReflectionField string } -func indirectReflection(v interface{}) { +func indirectReflection(v any) { fmt.Println(reflect.TypeOf(v).Field(0).Name) } diff --git a/testdata/scripts/reverse.txt b/testdata/scripts/reverse.txt index 4bf6ef4..fd1f97c 100644 --- a/testdata/scripts/reverse.txt +++ b/testdata/scripts/reverse.txt @@ -26,9 +26,7 @@ cp stderr build-error.stderr stdin build-error.stderr garble reverse ./build-error -# Go 1.18 changed the error format slightly. -[!go1.18] cmp stdout build-error-reverse.stdout-go1.17 -[go1.18] cmp stdout build-error-reverse.stdout-go1.18 +cmp stdout build-error-reverse.stdout [short] stop # no need to verify this with -short @@ -54,7 +52,7 @@ cmp stdout main-literals.stderr -- go.mod -- module test/main -go 1.17 +go 1.18 -- long_main.go -- package main @@ -157,12 +155,7 @@ main.main(...) test/main/long_main.go:11 +0x?? main filename: test/main/long_main.go --- build-error-reverse.stdout-go1.17 -- -# test/main/build-error -test/main/build-error/error.go:18: cannot convert UnobfuscatedStruct{} (type UnobfuscatedStruct) to type struct { SomeField int } -exit status 2 -exit status 2 --- build-error-reverse.stdout-go1.18 -- +-- build-error-reverse.stdout -- # test/main/build-error test/main/build-error/error.go:18: cannot convert UnobfuscatedStruct{} (value of type UnobfuscatedStruct) to type struct{SomeField int} exit status 2 diff --git a/testdata/scripts/seed-cache.txt b/testdata/scripts/seed-cache.txt index 0cb945a..78c4880 100644 --- a/testdata/scripts/seed-cache.txt +++ b/testdata/scripts/seed-cache.txt @@ -34,7 +34,7 @@ cd .. -- mod1/go.mod -- module test/main/mod1 -go 1.17 +go 1.18 require gopkg.in/garbletest.v2 v2.999.0 @@ -54,7 +54,7 @@ func main() { garbletest.Test() } -- mod2/go.mod -- module test/main/mod2 -go 1.17 +go 1.18 require gopkg.in/garbletest.v2 v2.999.0 diff --git a/testdata/scripts/seed.txt b/testdata/scripts/seed.txt index dd53e3e..d3364f0 100644 --- a/testdata/scripts/seed.txt +++ b/testdata/scripts/seed.txt @@ -99,7 +99,7 @@ cmp stderr importedpkg.stderr -- go.mod -- module test/main -go 1.17 +go 1.18 -- main.go -- package main @@ -131,7 +131,7 @@ func mainFunc() { // A workaround to fool garble's reflect detection, // because we want it to show us the obfuscated NamedType. -var NamedTypeValue interface{} = NamedType{} +var NamedTypeValue any = NamedType{} type NamedType struct { NamedField int @@ -159,7 +159,7 @@ func NamedFunc() string { return CallerFuncName() } -func PrintNames(v interface{}, fn func() string) { +func PrintNames(v any, fn func() string) { typ := reflect.TypeOf(v) println("path:", typ.PkgPath()) println("type:", typ.Name()) diff --git a/testdata/scripts/syntax.txt b/testdata/scripts/syntax.txt index a27cc57..6c7cc14 100644 --- a/testdata/scripts/syntax.txt +++ b/testdata/scripts/syntax.txt @@ -19,7 +19,7 @@ binsubstr main$exe 'globalVar' # 'globalType' matches on some, but not all, plat -- extra/go.mod -- module private.source/extra -go 1.17 +go 1.18 -- extra/extra.go -- package extra @@ -29,7 +29,7 @@ func Func() string { -- go.mod -- module test/main -go 1.17 +go 1.18 // We include an extra module to obfuscate, included in the same original source // code via a replace directive. @@ -48,7 +48,7 @@ import ( ) // This comment contains valuable information. Ensure it's not in the final binary. -var V interface{} +var V any type T struct { ast.Node @@ -193,7 +193,7 @@ func Test() { } } -func noop(...interface{}) {} +func noop(...any) {} // Funcs that almost look like test funcs used to make garble panic. diff --git a/testdata/scripts/test.txt b/testdata/scripts/test.txt index c7addd3..2fb7f4b 100644 --- a/testdata/scripts/test.txt +++ b/testdata/scripts/test.txt @@ -41,7 +41,7 @@ stdout 'package bar_test, func name: test/bar\.OriginalFuncName' -- go.mod -- module test/bar -go 1.17 +go 1.18 -- bar.go -- package bar diff --git a/testdata/scripts/tiny.txt b/testdata/scripts/tiny.txt index 34b0c41..b3942a6 100644 --- a/testdata/scripts/tiny.txt +++ b/testdata/scripts/tiny.txt @@ -26,14 +26,14 @@ stderr 'panic: oh noes' -- go.mod -- module test/main -go 1.17 +go 1.18 -- garble_main.go -- package main import "runtime" func main() { - var v interface{} = "tada" + var v any = "tada" println(v) defer func() {