Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: go work init won't create nested workspaces #53938

Open
thockin opened this issue Jul 18, 2022 · 2 comments
Open

cmd/go: go work init won't create nested workspaces #53938

thockin opened this issue Jul 18, 2022 · 2 comments
Labels
GoCommand modules NeedsInvestigation
Milestone

Comments

@thockin
Copy link

@thockin thockin commented Jul 18, 2022

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

$ go version
go version go1.18.1 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/thockin/.cache/go-build"
GOENV="/home/thockin/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/thockin/src/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/thockin/src/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/thockin/src/go-spew/go.mod"
GOWORK=""
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build907218417=/tmp/go-build -gno-record-gcc-switches"

What did you do?

CWD is a workspace, with a valid go.work file.

$ mkdir d

$ cd d

$ go work init
go: /home/thockin/src/kubernetes/go.work already exists

$ gotip version
go version devel go1.19-c0c1bbde17 Mon Jul 18 15:58:37 2022 +0000 linux/amd64

$ gotip work init
go: /home/thockin/src/kubernetes/go.work already exists

I am trying to isolate the deps in a sub-module from the deps in the workspace (as suggested in a different thread).

Manually creating a go.work file does achieve the ffect I wanted.

What did you expect to see?

I thought it would work

What did you see instead?

The above error

@seankhliao seankhliao changed the title workspaces: go work init does not work nested cmd/go: go work init won't create nested workspaces Jul 18, 2022
@seankhliao seankhliao added NeedsInvestigation GoCommand labels Jul 18, 2022
@seankhliao
Copy link
Member

@seankhliao seankhliao commented Jul 18, 2022

technically you could do GOWORK=off go work init

cc @bcmills @matloob

@bcmills bcmills added this to the Backlog milestone Jul 18, 2022
@bcmills
Copy link
Member

@bcmills bcmills commented Jul 18, 2022

For a self-contained reproducer:

$ cd subdir

subdir$ go work init .
go: /tmp/tmp.ekeCvusUDJ/go.work already exists

-- go.mod --
module example

go 1.19
-- go.work --
go 1.19

use .
-- subdir/go.mod --
module subdir/go.mod

go 1.19

I could see some room for debate about what should happen if the root go.work file already included ./subdir, but it doesn't. As far as I'm concerned, the go work init within subdir ought to succeed because the directory isn't already included in the existing workspace. (Compare #51604.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand modules NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

3 participants