]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modload: fix use of //go:linkname
authorHana Kim <hyangah@gmail.com>
Tue, 23 Oct 2018 05:29:40 +0000 (01:29 -0400)
committerHyang-Ah Hana Kim <hyangah@gmail.com>
Tue, 23 Oct 2018 14:06:18 +0000 (14:06 +0000)
I can't find the exact rule about space before compiler directive
openings from
https://golang.org/cmd/compile/#hdr-Compiler_Directives
but it seems like the compiler doesn't recognize it
as a compiler directive if it is preceded by space.
Removing the space made the //go:linkname in the __gomod__.go file
working as intended.

Manually tested.

Update #26404

Change-Id: I589f7203a628b2fa6238d82878029e0f098091b6
Reviewed-on: https://go-review.googlesource.com/c/143977
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/internal/modload/build.go

index 4e7741c5fb7834ac858d0c2e2e38f48ec02a83cd..a506c25dc7eb7c2df3574a858b5056d5f57d9dc1 100644 (file)
@@ -239,13 +239,10 @@ func ModInfoProg(info string) []byte {
        // 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.
-       return []byte(fmt.Sprintf(`
-               package main
-               import _ "unsafe"
-               //go:linkname __debug_modinfo__ runtime/debug.modinfo
-               var __debug_modinfo__ = ""
-               func init() {
-                       __debug_modinfo__ = %q
-               }
+       return []byte(fmt.Sprintf(`package main
+import _ "unsafe"
+//go:linkname __debug_modinfo__ runtime/debug.modinfo
+var __debug_modinfo__ = ""
+func init() { __debug_modinfo__ = %q }
        `, string(infoStart)+info+string(infoEnd)))
 }