...

Text file src/cmd/go/testdata/script/list_ignore_dependency.txt

Documentation: cmd/go/testdata/script

     1# go list should skip 'ignore' directives with respect to module boundaries.
     2# See golang.org/issue/42965
     3
     4env 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.
     9go list -x all
    10stdout 'example$'
    11stdout 'example/depA'
    12stderr '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.
    18go list -x ./...
    19stdout 'example$'
    20stderr '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.
    27go list -x example/...
    28stdout 'example$'
    29stdout 'example/depA'
    30stderr 'ignoring directory '$ROOT''${/}'node_modules'
    31stderr 'ignoring directory '$ROOT''${/}'depA'${/}'node_modules'
    32
    33# Entering the submodule should now cause go list to ignore depA/node_modules.
    34cd depA
    35go list -x all
    36stdout 'example/depA'
    37stderr 'ignoring directory '$ROOT''${/}'depA'${/}'node_modules'
    38! stderr 'ignoring directory '$ROOT''${/}'node_modules'
    39
    40go list -x ./...
    41stdout 'example/depA'
    42stderr 'ignoring directory '$ROOT''${/}'depA'${/}'node_modules'
    43! stderr 'ignoring directory '$ROOT''${/}'node_modules'
    44
    45-- depA/go.mod --
    46module example/depA
    47
    48go 1.24
    49ignore ./node_modules
    50-- depA/depA.go --
    51package depA
    52
    53const Foo = "This is Foo!"
    54-- depA/node_modules/some_pkg/index.js --
    55console.log("This should be ignored!");
    56-- node_modules/some_pkg/index.js --
    57console.log("This should be ignored!");
    58-- go.mod --
    59module example
    60
    61go 1.24
    62
    63ignore ./node_modules
    64require example/depA v1.0.0
    65replace example/depA => ./depA
    66
    67-- main.go --
    68package main
    69import (
    70        "fmt"
    71        "example/depA"
    72)
    73func main() {
    74        fmt.Println("test")
    75        fmt.Println(depA.Foo)
    76}

View as plain text