...
1# go list should skip 'ignore' directives in workspaces
2# See golang.org/issue/42965
3
4env ROOT=$WORK${/}gopath${/}src
5
6# go list ./... should only consider the current module's ignore directive
7cd moduleA
8go list -x ./...
9stdout 'moduleA$'
10stdout 'moduleA/pkg$'
11stderr 'ignoring directory '$ROOT''${/}'moduleA'${/}'node_modules'
12
13# go list ./... should only consider the current module's ignore directive
14cd ../moduleB
15go list -x ./...
16stdout 'moduleB$'
17! stdout 'moduleB/pkg/helper'
18stderr 'ignoring directory '$ROOT''${/}'moduleB'${/}'pkg'
19
20# go list should respect module boundaries for ignore directives.
21# moduleA ignores './node_modules', moduleB ignores 'pkg'
22cd ..
23go list -x all
24stderr 'ignoring directory '$ROOT''${/}'moduleA'${/}'node_modules'
25stderr 'ignoring directory '$ROOT''${/}'moduleB'${/}'pkg'
26! stderr 'ignoring directory '$ROOT''${/}'moduleA'${/}'pkg'
27stdout 'moduleA$'
28stdout 'moduleA/pkg$'
29stdout 'moduleB$'
30stdout 'moduleB/pkg/helper'
31
32-- go.work --
33go 1.24
34
35use (
36 ./moduleA
37 ./moduleB
38)
39
40-- moduleA/go.mod --
41module moduleA
42
43go 1.24
44
45ignore ./node_modules
46
47-- moduleA/main.go --
48package main
49
50import (
51 "fmt"
52 "moduleB/pkg/helper"
53)
54
55func main() {
56 fmt.Println("Running moduleA")
57 fmt.Println(helper.Message())
58 fmt.Println(hello.Hello())
59}
60-- moduleA/node_modules/some_pkg/index.js --
61console.log("This should be ignored!");
62-- moduleA/pkg/hello.go --
63package hello
64
65func Hello() string {
66 return "Hello from moduleA"
67}
68-- moduleB/go.mod --
69module moduleB
70
71go 1.24
72
73ignore pkg
74
75-- moduleB/main.go --
76package main
77
78import "fmt"
79
80func main() {
81 fmt.Println("Running moduleB")
82}
83
84-- moduleB/pkg/helper/helper.go --
85package helper
86
87func Message() string {
88 return "Helper from moduleB"
89}
View as plain text