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: mod tidy doesn't look in GOPATH when converting a legacy GOPATH project #42441
Comments
The problem is that before you can run |
@stevetraut is working on new tutorial content for modules. (We should take this feedback into account in the tutorials.) |
I think the first place folks will look for information about what the command requires to run usefully is in the reference for go mod tidy. This behavior should be reflect in other module docs, but I don't think people will look there first because it's less immediate. |
In this case, I think what we're missing is probably a tutorial on “converting a GOPATH project to use modules” when the existing (Our existing blog post assumes that the whole |
Can we set aside the content delivery vehicle for a moment and focus on what users need to be successful? What bits of information does a user need to have in order to successfully migrate GOPATH code to modules? |
In this particular case, the user needs to know that they should add |
At this point I'm not sure that it's worth adding a lot of new documentation on converting legacy projects, as a significant fraction of projects have already been converted to modules. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Migrating legacy GOPATH code to use modules. Following this blog post I run
go mod init bitbucket.org/username/reponame.git/integration-project/golang/lctlk8s
in the project root directory. Then I rungo mod tidy
it gives$GOPATH/go.mod exists but should not
If I change to the src/ directory and create the go.mod and run go tidy it fails to find to code in the current project and GOPATH:
go mod tidy
bitbucket.org/username/reponame.git/integration-project/golang/lctlk8s/cmd/lctlk8s imports
internal/composerestclient: package internal/composerestclient is not in GOROOT (/home/dean/bin/go1.14.linux-amd64/go/src/internal/composerestclient)
bitbucket.org/username/reponame.git/integration-project/golang/lctlk8s/internal/composerestclient imports
pkg/lctlutil: package pkg/lctlutil is not in GOROOT (/home/dean/bin/go1.14.linux-amd64/go/src/pkg/lctlutil)
Is this a bug in
go mod tidy
for not looking in the GOPATH, or is the blog post just wrong about how to migrate a legacy GOPATH project?Here's my tree under the project root:
└── src
├── cmd
│ └── lctlk8s
│ └── lctlk8s.go
├── internal
│ ├── composerestclient
│ │ ├── compose.rest.client.go
│ │ ├── json.strings.go
│ │ ├── rest.client.structs.go
│ │ └── version.go
└── pkg
├── lctlutil
│ ├── readascii.go
│ └── readconf.go
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: