mirror of
https://github.com/burrowers/garble.git
synced 2025-10-01 06:02:10 +08:00
all: drop support for Go 1.17
Now that we've released v0.6.0, that will be the last feature release to feature support for Go 1.17. The upcoming v0.7.0 will be Go 1.18+. Code-wise, the cleanup here isn't super noticeable, but it will be easier to work on features like VCS-aware version information and generics support without worrying about Go 1.17. Plus, now CI is back to being much faster. Note how "go 1.18" in go.mod makes "go mod tidy" more aggressive.
This commit is contained in:
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
@@ -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"
|
||||
|
@@ -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]
|
||||
|
||||
|
2
go.mod
2
go.mod
@@ -1,6 +1,6 @@
|
||||
module mvdan.cc/garble
|
||||
|
||||
go 1.17
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/frankban/quicktest v1.14.2
|
||||
|
22
go.sum
22
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=
|
||||
|
14
main.go
14
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.
|
||||
|
@@ -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")
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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
|
||||
|
2
testdata/scripts/asm.txt
vendored
2
testdata/scripts/asm.txt
vendored
@@ -23,7 +23,7 @@ binsubstr main$exe 'privateAdd' 'PublicAdd'
|
||||
-- go.mod --
|
||||
module test/main
|
||||
|
||||
go 1.17
|
||||
go 1.18
|
||||
-- main.go --
|
||||
package main
|
||||
|
||||
|
2
testdata/scripts/basic.txt
vendored
2
testdata/scripts/basic.txt
vendored
@@ -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
|
||||
|
||||
|
2
testdata/scripts/cgo.txt
vendored
2
testdata/scripts/cgo.txt
vendored
@@ -27,7 +27,7 @@ binsubstr main$exe 'privateAdd'
|
||||
-- go.mod --
|
||||
module test/main
|
||||
|
||||
go 1.17
|
||||
go 1.18
|
||||
-- main.go --
|
||||
package main
|
||||
|
||||
|
2
testdata/scripts/crossbuild.txt
vendored
2
testdata/scripts/crossbuild.txt
vendored
@@ -15,7 +15,7 @@ garble build
|
||||
-- go.mod --
|
||||
module test/main
|
||||
|
||||
go 1.17
|
||||
go 1.18
|
||||
-- main.go --
|
||||
package main
|
||||
|
||||
|
2
testdata/scripts/debugdir.txt
vendored
2
testdata/scripts/debugdir.txt
vendored
@@ -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
|
||||
|
||||
|
2
testdata/scripts/embed.txt
vendored
2
testdata/scripts/embed.txt
vendored
@@ -14,7 +14,7 @@ cmp stdout main.stdout
|
||||
-- go.mod --
|
||||
module test/main
|
||||
|
||||
go 1.17
|
||||
go 1.18
|
||||
|
||||
-- main.go --
|
||||
package main
|
||||
|
2
testdata/scripts/gogarble.txt
vendored
2
testdata/scripts/gogarble.txt
vendored
@@ -50,7 +50,7 @@ bincmp out_rebuild out
|
||||
-- go.mod --
|
||||
module test/main
|
||||
|
||||
go 1.17
|
||||
go 1.18
|
||||
-- standalone/main.go --
|
||||
package main
|
||||
|
||||
|
22
testdata/scripts/goversion.txt
vendored
22
testdata/scripts/goversion.txt
vendored
@@ -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
|
||||
|
||||
|
4
testdata/scripts/implement.txt
vendored
4
testdata/scripts/implement.txt
vendored
@@ -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
|
||||
|
4
testdata/scripts/imports.txt
vendored
4
testdata/scripts/imports.txt
vendored
@@ -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 --
|
||||
|
2
testdata/scripts/init.txt
vendored
2
testdata/scripts/init.txt
vendored
@@ -13,7 +13,7 @@ cmp stderr main.stderr
|
||||
-- go.mod --
|
||||
module test/main
|
||||
|
||||
go 1.17
|
||||
go 1.18
|
||||
-- main.go --
|
||||
package main
|
||||
|
||||
|
2
testdata/scripts/ldflags.txt
vendored
2
testdata/scripts/ldflags.txt
vendored
@@ -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
|
||||
|
||||
|
6
testdata/scripts/linkname.txt
vendored
6
testdata/scripts/linkname.txt
vendored
@@ -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
|
||||
|
2
testdata/scripts/literals.txt
vendored
2
testdata/scripts/literals.txt
vendored
@@ -57,7 +57,7 @@ garble -literals build std
|
||||
-- go.mod --
|
||||
module test/main
|
||||
|
||||
go 1.17
|
||||
go 1.18
|
||||
-- main.go --
|
||||
package main
|
||||
|
||||
|
9
testdata/scripts/modinfo.txt
vendored
9
testdata/scripts/modinfo.txt
vendored
@@ -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
|
||||
|
||||
|
2
testdata/scripts/plugin.txt
vendored
2
testdata/scripts/plugin.txt
vendored
@@ -29,7 +29,7 @@ cmp stderr main.stderr
|
||||
-- go.mod --
|
||||
module test/main
|
||||
|
||||
go 1.17
|
||||
go 1.18
|
||||
-- plugin/main.go --
|
||||
package main
|
||||
|
||||
|
2
testdata/scripts/position.txt
vendored
2
testdata/scripts/position.txt
vendored
@@ -19,7 +19,7 @@ stdout 'varPositions is sorted'
|
||||
-- go.mod --
|
||||
module test/main
|
||||
|
||||
go 1.17
|
||||
go 1.18
|
||||
-- garble_main.go --
|
||||
package main
|
||||
|
||||
|
6
testdata/scripts/reflect.txt
vendored
6
testdata/scripts/reflect.txt
vendored
@@ -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)
|
||||
}
|
||||
|
||||
|
13
testdata/scripts/reverse.txt
vendored
13
testdata/scripts/reverse.txt
vendored
@@ -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
|
||||
|
4
testdata/scripts/seed-cache.txt
vendored
4
testdata/scripts/seed-cache.txt
vendored
@@ -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
|
||||
|
||||
|
6
testdata/scripts/seed.txt
vendored
6
testdata/scripts/seed.txt
vendored
@@ -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())
|
||||
|
8
testdata/scripts/syntax.txt
vendored
8
testdata/scripts/syntax.txt
vendored
@@ -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.
|
||||
|
||||
|
2
testdata/scripts/test.txt
vendored
2
testdata/scripts/test.txt
vendored
@@ -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
|
||||
|
||||
|
4
testdata/scripts/tiny.txt
vendored
4
testdata/scripts/tiny.txt
vendored
@@ -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() {
|
||||
|
Reference in New Issue
Block a user