| 1 |
# For 1.23+, vendored packages that are missing in modules.txt should result in an error. |
| 2 |
cp incorrect_modules.txt vendor/modules.txt |
| 3 |
# incorrect_modules is missing foo.com/internal/bar/b so the build should fail. |
| 4 |
! go build ./vendor/foo.com/internal/bar/a |
| 5 |
stderr 'cannot find module providing package foo.com/internal/bar/b: import lookup disabled by -mod=vendor' |
| 6 |
stderr 'go: ignoring package foo.com/internal/bar/b which exists in the vendor directory but is missing from vendor/modules.txt. To sync the vendor directory run go mod vendor.' |
| 7 |
|
| 8 |
cp correct_modules.txt vendor/modules.txt |
| 9 |
go build ./vendor/foo.com/internal/bar/a |
| 10 |
|
| 11 |
# For go versions < 1.23, vendored packages that are missing in modules.txt should not result in an error. |
| 12 |
cp 122go.mod go.mod |
| 13 |
|
| 14 |
cp incorrect_modules.txt vendor/modules.txt |
| 15 |
|
| 16 |
# go version < 1.23 and incorrect_modules is missing foo.com/internal/bar/b so the build should not fail |
| 17 |
go build ./vendor/foo.com/internal/bar/a |
| 18 |
|
| 19 |
cp correct_modules.txt vendor/modules.txt |
| 20 |
go build ./vendor/foo.com/internal/bar/a |
| 21 |
|
| 22 |
-- 122go.mod -- |
| 23 |
module example.com/x |
| 24 |
go 1.22 |
| 25 |
|
| 26 |
require "foo.com/internal/bar" v1.0.0 |
| 27 |
|
| 28 |
-- go.mod -- |
| 29 |
module example.com/x |
| 30 |
go 1.23 |
| 31 |
|
| 32 |
require "foo.com/internal/bar" v1.0.0 |
| 33 |
|
| 34 |
-- incorrect_modules.txt -- |
| 35 |
# foo.com/internal/bar v1.0.0 |
| 36 |
## explicit |
| 37 |
foo.com/internal/bar/a |
| 38 |
|
| 39 |
-- correct_modules.txt -- |
| 40 |
# foo.com/internal/bar v1.0.0 |
| 41 |
## explicit |
| 42 |
foo.com/internal/bar/a |
| 43 |
foo.com/internal/bar/b |
| 44 |
|
| 45 |
-- vendor/foo.com/internal/bar/a/a.go -- |
| 46 |
package a |
| 47 |
import _ "foo.com/internal/bar/b" |
| 48 |
|
| 49 |
-- vendor/foo.com/internal/bar/b/b.go -- |
| 50 |
package b |