github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/mod_goroot_errors.txt (about) 1 env GO111MODULE=on 2 3 # Regression test for https://golang.org/issue/34769. 4 # Missing standard-library imports should refer to GOROOT rather than 5 # complaining about a malformed module path. 6 # This is especially important when GOROOT is set incorrectly, 7 # since such an error will occur for every package in std. 8 9 # Building a nonexistent std package directly should fail usefully. 10 11 ! go build -mod=readonly nonexist 12 ! stderr 'import lookup disabled' 13 ! stderr 'missing dot' 14 stderr '^can''t load package: package nonexist is not in GOROOT \('$GOROOT'[/\\]src[/\\]nonexist\)$' 15 16 ! go build nonexist 17 ! stderr 'import lookup disabled' 18 ! stderr 'missing dot' 19 stderr '^can''t load package: package nonexist is not in GOROOT \('$GOROOT'[/\\]src[/\\]nonexist\)$' 20 21 # Building a nonexistent std package indirectly should also fail usefully. 22 23 ! go build -mod=readonly ./importnonexist 24 ! stderr 'import lookup disabled' 25 ! stderr 'missing dot' 26 stderr '^importnonexist[/\\]x.go:2:8: package nonexist is not in GOROOT \('$GOROOT'[/\\]src[/\\]nonexist\)$' 27 28 ! go build ./importnonexist 29 ! stderr 'import lookup disabled' 30 ! stderr 'missing dot' 31 stderr '^importnonexist[/\\]x.go:2:8: package nonexist is not in GOROOT \('$GOROOT'[/\\]src[/\\]nonexist\)$' 32 33 # Building an *actual* std package should fail if GOROOT is set to something bogus. 34 35 [!short] go build ./importjson # Prove that it works when GOROOT is valid. 36 37 env GOROOT=$WORK/not-a-valid-goroot 38 ! go build ./importjson 39 ! stderr 'import lookup disabled' 40 ! stderr 'missing dot' 41 stderr 'importjson[/\\]x.go:2:8: package encoding/json is not in GOROOT \('$WORK'[/\\]not-a-valid-goroot[/\\]src[/\\]encoding[/\\]json\)$' 42 43 -- go.mod -- 44 module example.com 45 go 1.14 46 -- importnonexist/x.go -- 47 package importnonexist 48 import _ "nonexist" 49 -- importjson/x.go -- 50 package importjson 51 import _ "encoding/json" 52 -- $WORK/not-a-valid-goroot/README -- 53 This directory is not a valid GOROOT.