...

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

Documentation: cmd/go/testdata/script

     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 ./...
     7stderr 'pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies'
     8
     9! go list ./a/c
    10stderr '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
    13stderr '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
    15cd a/c
    16! go run .
    17stderr '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
    19cd ../..
    20! go run .
    21stderr 'current directory outside modules listed in go.work or their selected dependencies'
    22
    23-- go.work --
    24go 1.18
    25
    26use ./b
    27-- a/go.mod --
    28module example.com/a
    29
    30go 1.18
    31-- a/a.go --
    32package a
    33-- a/c/c.go --
    34package main
    35-- b/go.mod --
    36module example.com/b
    37
    38go 1.18
    39-- foo.go --
    40package foo

View as plain text