github.com/zxy12/go_duplicate_112_new@v0.0.0-20200807091221-747231827200/src/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 require example.com/internal v0.0.0 24 replace example.com/internal => ../internal 25 26 -- foo/internal.go -- 27 package foo 28 import _ "example.com/internal" 29 30 -- foo/foo_test.go -- 31 package foo_test 32 33 import ( 34 "testing" 35 "example.com/internal" 36 ) 37 38 func TestHacksEnabled(t *testing.T) { 39 if !internal.Hacks { 40 t.Fatal("hacks not enabled") 41 } 42 } 43 44 -- internal/go.mod -- 45 module example.com/internal 46 47 -- internal/internal.go -- 48 package internal 49 const Hacks = true