1 [!buildmode:shared] skip
2 [short] skip
3 [!cgo] skip '-buildmode=shared requires external linking'
4
5 env GO111MODULE=off
6 env CGO_ENABLED=1
7
8 # -trimpath should keep GOROOT out of shared libraries too.
9 go install -trimpath -buildmode=shared -pkgdir=$WORK/pkgdir runtime
10 go build -trimpath -linkshared -pkgdir=$WORK/pkgdir -o goroot$GOEXE goroot.go
11 env GOROOT=
12 exec ./goroot$GOEXE
13 stderr '^GOROOT=$'
14
15 -- goroot.go --
16 package main
17
18 import "runtime"
19
20 func main() {
21 println("GOROOT=" + runtime.GOROOT())
22 }
23
View as plain text