]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: remove init() to fix precedence issue when setting debug mod info
authorViacheslav Poturaev <vearutop@gmail.com>
Wed, 9 Jan 2019 12:54:50 +0000 (12:54 +0000)
committerBryan C. Mills <bcmills@google.com>
Tue, 15 Jan 2019 17:43:53 +0000 (17:43 +0000)
Fixes #29628

Change-Id: I95dabed797ef7a1a770b6f4219840f653306af7e
GitHub-Last-Rev: 9275dd8f1c6a0cfa16ae882fcfc100991f8338f7
GitHub-Pull-Request: golang/go#29630
Reviewed-on: https://go-review.googlesource.com/c/157097
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/go/internal/modload/build.go

index efeb7a5fd5d055ff584e8db7d7d9add46f0ca05b..70740aeacd6149a2846df9e4f20c9100e4bd490c 100644 (file)
@@ -252,13 +252,10 @@ func findModule(target, path string) module.Version {
 func ModInfoProg(info string) []byte {
        // Inject a variable with the debug information as runtime/debug.modinfo,
        // but compile it in package main so that it is specific to the binary.
-       // Populate it in an init func so that it will work with go:linkname,
-       // but use a string constant instead of the name 'string' in case
-       // package main shadows the built-in 'string' with some local declaration.
+       // No need to populate in an init func, it will still work with go:linkname,
        return []byte(fmt.Sprintf(`package main
 import _ "unsafe"
 //go:linkname __debug_modinfo__ runtime/debug.modinfo
-var __debug_modinfo__ = ""
-func init() { __debug_modinfo__ = %q }
+var __debug_modinfo__ = %q
        `, string(infoStart)+info+string(infoEnd)))
 }