Skip to content

Commit c9bc134

Browse files
committed
cmd/go/internal/modload: fix use of //go:linkname
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 <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent b171b28 commit c9bc134

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

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

+5-8
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,10 @@ func ModInfoProg(info string) []byte {
239239
// Populate it in an init func so that it will work with go:linkname,
240240
// but use a string constant instead of the name 'string' in case
241241
// package main shadows the built-in 'string' with some local declaration.
242-
return []byte(fmt.Sprintf(`
243-
package main
244-
import _ "unsafe"
245-
//go:linkname __debug_modinfo__ runtime/debug.modinfo
246-
var __debug_modinfo__ = ""
247-
func init() {
248-
__debug_modinfo__ = %q
249-
}
242+
return []byte(fmt.Sprintf(`package main
243+
import _ "unsafe"
244+
//go:linkname __debug_modinfo__ runtime/debug.modinfo
245+
var __debug_modinfo__ = ""
246+
func init() { __debug_modinfo__ = %q }
250247
`, string(infoStart)+info+string(infoEnd)))
251248
}

0 commit comments

Comments
 (0)