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

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

View as plain text