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

     1  # This is a regression test for issue #49632.
     2  # The Go command should mention go.work if the user
     3  # tries to load a local package that's in a module
     4  # that's not in go.work and can't be resolved.
     5  
     6  ! go list ./...
     7  stderr 'pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies'
     8  
     9  ! go list ./a/c
    10  stderr 'directory a[\\/]c is contained in a module that is not one of the workspace modules listed in go.work. You can add the module to the workspace using:\n\tgo work use a'
    11  
    12  ! go install ./a/c
    13  stderr 'directory a[\\/]c is contained in a module that is not one of the workspace modules listed in go.work. You can add the module to the workspace using:\n\tgo work use a'
    14  
    15  cd a/c
    16  ! go run .
    17  stderr 'current directory is contained in a module that is not one of the workspace modules listed in go.work. You can add the module to the workspace using:\n\tgo work use \.\.'
    18  
    19  cd ../..
    20  ! go run .
    21  stderr 'current directory outside modules listed in go.work or their selected dependencies'
    22  
    23  -- go.work --
    24  go 1.18
    25  
    26  use ./b
    27  -- a/go.mod --
    28  module example.com/a
    29  
    30  go 1.18
    31  -- a/a.go --
    32  package a
    33  -- a/c/c.go --
    34  package main
    35  -- b/go.mod --
    36  module example.com/b
    37  
    38  go 1.18
    39  -- foo.go --
    40  package foo
    41  

View as plain text