...
1# Test that mod=vendor is disabled in workspace mode, even
2# with a single workspace module.
3
4cd workspace
5
6# Base case: ensure the module would default to mod=vendor
7# outside of workspace mode.
8env GOWORK=off
9go list -f '{{.Dir}}' example.com/dep
10stdout $GOPATH[\\/]src[\\/]workspace[\\/]vendor[\\/]example.com[\\/]dep
11
12# Test case: endure the module does not enter mod=vendor outside
13# worspace mode.
14env GOWORK=''
15go list -f '{{.Dir}}' example.com/dep
16stdout $GOPATH[\\/]src[\\/]dep
17
18-- workspace/go.work --
19use .
20replace example.com/dep => ../dep
21-- workspace/main.go --
22package main
23
24import "example.com/dep"
25
26func main() {
27 dep.Dep()
28}
29-- workspace/go.mod --
30module example.com/mod
31
32go 1.20
33
34require example.com/dep v1.0.0
35-- workspace/vendor/example.com/dep/dep.go --
36package dep
37
38import "fmt"
39
40func Dep() {
41 fmt.Println("the vendored dep")
42}
43-- workspace/vendor/modules.txt --
44# example.com/dep v1.0.0
45## explicit
46example.com/dep
47-- dep/go.mod --
48module example.com/dep
49-- dep/dep.go --
50package dep
51
52import "fmt"
53
54func Dep () {
55 fmt.Println("the real dep")
56}
View as plain text