github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/mod_test_files.txt (about) 1 env GO111MODULE=on 2 3 cd foo 4 5 # Testing an explicit source file should use the same import visibility as the 6 # package in the same directory. 7 go list -test -deps 8 go list -test -deps foo_test.go 9 10 # If the file is inside the main module's vendor directory, it should have 11 # visibility based on the vendor-relative import path. 12 mkdir vendor/example.com/foo 13 cp foo_test.go vendor/example.com/foo 14 go list -test -deps vendor/example.com/foo/foo_test.go 15 16 # If the file is outside the main module entirely, it should be treated as outside. 17 cp foo_test.go ../foo_test.go 18 ! go list -test -deps ../foo_test.go 19 stderr 'use of internal package' 20 21 -- foo/go.mod -- 22 module example.com/foo 23 go 1.12 24 require example.com/internal v0.0.0 25 replace example.com/internal => ../internal 26 27 -- foo/internal.go -- 28 package foo 29 import _ "example.com/internal" 30 31 -- foo/foo_test.go -- 32 package foo_test 33 34 import ( 35 "testing" 36 "example.com/internal" 37 ) 38 39 func TestHacksEnabled(t *testing.T) { 40 if !internal.Hacks { 41 t.Fatal("hacks not enabled") 42 } 43 } 44 45 -- internal/go.mod -- 46 module example.com/internal 47 48 -- internal/internal.go -- 49 package internal 50 const Hacks = true