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 mod tidy failed in workspace mode #52962

Closed
maxsxu opened this issue May 18, 2022 · 2 comments
Closed

cmd/go: go mod tidy failed in workspace mode #52962

maxsxu opened this issue May 18, 2022 · 2 comments

Comments

@maxsxu
Copy link

maxsxu commented May 18, 2022

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

$ go version
go version go1.18.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/max/Library/Caches/go-build"
GOENV="/Users/max/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/max/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/max/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/opt/go/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/tx/5c8vkq6x2k1f5nqvbj271qyc0000gn/T/go-build15601913=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Reproduction steps:

  1. Clone test project git clone https://github.com/maxsxu/go-workspace
  2. Run cd server && go mod tidy

The project structure:

go-workspace         
├── commons
│   ├── pkg
│   │   └── util.go
│   └── go.mod
├── server
│   ├── go.mod
│   └── main.go
└── go.work

The commons/go.mod file:

module atmax.io/go-workspace/commons

go 1.18

The server/go.mod file:

module atmax.io/go-workspace/server

go 1.18

The go mod tidy failed with below errors:

➜  server  go mod tidy    
go: finding module for package atmax.io/go-workspace/commons/pkg
atmax.io/go-workspace/server imports
        atmax.io/go-workspace/commons/pkg: cannot find module providing package atmax.io/go-workspace/commons/pkg: unrecognized import path "atmax.io/go-workspace/commons/pkg": reading https://atmax.io/go-workspace/commons/pkg?go-get=1: 404 Not Found

What did you expect to see?

The go mod tidy should not try to find modules which have been declared in go.work.

What did you see instead?

The go mod tidy try to find modules which have been declared in go.work, and these modules cannot be found in internet, which causes failed.

But the go run command works well.

@seankhliao
Copy link
Member

Duplicate of #50750

@seankhliao seankhliao marked this as a duplicate of #50750 May 18, 2022
@maxsxu
Copy link
Author

maxsxu commented May 18, 2022

Furthermore, some other go mod commands also failed.

  • go mod vendor
➜  server   go mod vendor 
atmax.io/go-workspace/server imports
        atmax.io/go-workspace/commons/pkg: no required module provides package atmax.io/go-workspace/commons/pkg; to add it:
        go get atmax.io/go-workspace/commons/pkg
  • go mod verify
➜  server   go mod verify 
atmax.io/go-workspace/server : missing ziphash: open hash: no such file or directory

@golang golang locked and limited conversation to collaborators May 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants