...

Text file src/cmd/go/testdata/script/build_link_x_import_path_escape.txt

Documentation: cmd/go/testdata/script

     1[compiler:gccgo] skip 'gccgo does not support -ldflags -X'
     2
     3go build -o linkx$GOEXE -ldflags -X=my.pkg.Text=linkXworked my.pkg/main
     4exec ./linkx$GOEXE
     5stderr '^linkXworked$'
     6
     7-- go.mod --
     8module my.pkg
     9
    10go 1.16
    11-- main/main.go --
    12package main
    13
    14import "my.pkg"
    15
    16func main() {
    17	println(pkg.Text)
    18}
    19-- pkg.go --
    20package pkg
    21
    22var Text = "unset"

View as plain text