You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible (and I believe intended as a valid practice) to vendor a stdlib package and have it "shadow" the package in $GOROOT.
However, the testmain program constructed by go test doesn't use such vendored stdlib packages. In particular, this prevents vendoring package "testing"; the testmain program refers to the GOROOT testing package, where as the package under test uses the vendored testing package. Thus the testmain program does not compile and so go test cannot work.
Demo:
$ export GOPATH=/tmp/gopath
$ mkdir -p $GOPATH/src/x
$ cd $GOPATH/src/x
$ cat > x_test.go
package x
import "testing"
func TestX(t *testing.T) {}
$ go test
PASS
ok x 0.009s
$ mkdir -p $GOPATH/src/vendor
$ cp -r ~/apps/go/src/testing $GOPATH/src/vendor/ # vendor testing from your usual GOROOT
$ go test
# testmain
/var/folders/7r/pz2frytd23gb3pt4bwwshp1c0000gn/T/go-build151556267/x/_test/_testmain.go:22: cannot use x.TestX (type func(*"vendor/testing".T)) as type func(*"testing".T) in field value
FAIL x [build failed]
The text was updated successfully, but these errors were encountered:
go 1.6 linux/amd64
It is possible (and I believe intended as a valid practice) to vendor a stdlib package and have it "shadow" the package in $GOROOT.
However, the testmain program constructed by
go test
doesn't use such vendored stdlib packages. In particular, this prevents vendoring package "testing"; the testmain program refers to the GOROOT testing package, where as the package under test uses the vendored testing package. Thus the testmain program does not compile and sogo test
cannot work.Demo:
The text was updated successfully, but these errors were encountered: