From 3f35fb07f2d8f45f67aa5047ea6c653fd0f74fd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 8 Dec 2019 21:32:37 +0000 Subject: [PATCH] remove module info from the resulting binary --- main.go | 3 +++ testdata/scripts/modinfo.txt | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 testdata/scripts/modinfo.txt diff --git a/main.go b/main.go index a5df2e0..6fd4493 100644 --- a/main.go +++ b/main.go @@ -174,6 +174,9 @@ func transformCompile(args []string) ([]string, error) { // log.Printf("%#v", ids) var files []*ast.File for _, path := range paths { + if strings.HasSuffix(path, "_gomod_.go") { + continue // don't include module info + } file, err := parser.ParseFile(fset, path, nil, 0) if err != nil { return nil, err diff --git a/testdata/scripts/modinfo.txt b/testdata/scripts/modinfo.txt new file mode 100644 index 0000000..f7a1abf --- /dev/null +++ b/testdata/scripts/modinfo.txt @@ -0,0 +1,26 @@ +exec go build +exec ./main +cmp stdout main.stdout-orig + +garble build +exec ./main +cmp stdout main.stdout +! grep '\(devel\)' main + +-- go.mod -- +module foo.com/main +-- main.go -- +package main + +import ( + "fmt" + "runtime/debug" +) + +func main() { + fmt.Println(debug.ReadBuildInfo()) +} +-- main.stdout-orig -- +&{foo.com/main {foo.com/main (devel) } []} true +-- main.stdout -- + false