| 1 |
# go list should skip 'ignore' directives with respect to module boundaries. |
| 2 |
# See golang.org/issue/42965 |
| 3 |
|
| 4 |
env ROOT=$WORK${/}gopath${/}src |
| 5 |
|
| 6 |
# Lists all packages known to the Go toolchain. |
| 7 |
# Since go list already does not traverse into other modules found in |
| 8 |
# subdirectories, it should only ignore the root node_modules. |
| 9 |
go list -x all |
| 10 |
stdout 'example$' |
| 11 |
stdout 'example/depA' |
| 12 |
stderr 'ignoring directory '$ROOT''${/}'node_modules' |
| 13 |
! stderr 'ignoring directory '$ROOT''${/}'depA'${/}'node_modules' |
| 14 |
|
| 15 |
# Lists all packages within the current Go module. |
| 16 |
# Since go list already does not traverse into other modules found in |
| 17 |
# subdirectories, it should only ignore the root node_modules. |
| 18 |
go list -x ./... |
| 19 |
stdout 'example$' |
| 20 |
stderr 'ignoring directory '$ROOT''${/}'node_modules' |
| 21 |
! stderr 'ignoring directory '$ROOT''${/}'depA'${/}'node_modules' |
| 22 |
|
| 23 |
# Lists all packages belonging to the module whose import path starts with |
| 24 |
# example. |
| 25 |
# In this case, go list will traverse into each module that starts with example. |
| 26 |
# So it should ignore the root node_modules and the subdirectories' node_modules. |
| 27 |
go list -x example/... |
| 28 |
stdout 'example$' |
| 29 |
stdout 'example/depA' |
| 30 |
stderr 'ignoring directory '$ROOT''${/}'node_modules' |
| 31 |
stderr 'ignoring directory '$ROOT''${/}'depA'${/}'node_modules' |
| 32 |
|
| 33 |
# Entering the submodule should now cause go list to ignore depA/node_modules. |
| 34 |
cd depA |
| 35 |
go list -x all |
| 36 |
stdout 'example/depA' |
| 37 |
stderr 'ignoring directory '$ROOT''${/}'depA'${/}'node_modules' |
| 38 |
! stderr 'ignoring directory '$ROOT''${/}'node_modules' |
| 39 |
|
| 40 |
go list -x ./... |
| 41 |
stdout 'example/depA' |
| 42 |
stderr 'ignoring directory '$ROOT''${/}'depA'${/}'node_modules' |
| 43 |
! stderr 'ignoring directory '$ROOT''${/}'node_modules' |
| 44 |
|
| 45 |
-- depA/go.mod -- |
| 46 |
module example/depA |
| 47 |
|
| 48 |
go 1.24 |
| 49 |
ignore ./node_modules |
| 50 |
-- depA/depA.go -- |
| 51 |
package depA |
| 52 |
|
| 53 |
const Foo = "This is Foo!" |
| 54 |
-- depA/node_modules/some_pkg/index.js -- |
| 55 |
console.log("This should be ignored!"); |
| 56 |
-- node_modules/some_pkg/index.js -- |
| 57 |
console.log("This should be ignored!"); |
| 58 |
-- go.mod -- |
| 59 |
module example |
| 60 |
|
| 61 |
go 1.24 |
| 62 |
|
| 63 |
ignore ./node_modules |
| 64 |
require example/depA v1.0.0 |
| 65 |
replace example/depA => ./depA |
| 66 |
|
| 67 |
-- main.go -- |
| 68 |
package main |
| 69 |
import ( |
| 70 |
"fmt" |
| 71 |
"example/depA" |
| 72 |
) |
| 73 |
func main() { |
| 74 |
fmt.Println("test") |
| 75 |
fmt.Println(depA.Foo) |
| 76 |
} |