Skip to content

cmd/go: work use . does nothing in non module root #53090

@seankhliao

Description

@seankhliao

What version of Go are you using (go version)?

$ go version
go version devel go1.19-0ab71cc065 Thu May 26 04:57:33 2022 +0000 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/arccy/.cache/go-build"
GOENV="/home/arccy/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/arccy/.data/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/arccy/.data/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/arccy/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/arccy/sdk/gotip/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.19-0ab71cc065 Thu May 26 04:57:33 2022 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/arccy/tmp/testrepo-905/a/go.mod"
GOWORK="/home/arccy/tmp/testrepo-905/go.work"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4081894270=/tmp/go-build -gno-record-gcc-switches"

What did you do?

with the following directory tree:

.
├── a
│  ├── b
│  │  └── doc.go
│  └── go.mod
└── go.work

run go work use . in a/b

What did you expect to see?

module defined at a/go.mod added to go.work

What did you see instead?

nothing happened (see also #51965)

notes

go help work use says usage: go work use [-r] moddirs,
but it would be more ergonomic to have go look upwards for the moddir,
essentially: go work use $(dirname $(go env GOMOD))

cc @bcmills @matloob

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions