-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: can't parse go.mod with branch or commit hash specifier #42411
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
Comments
You're meant to use |
If we are not supposed to manually edit go.mod that needs to be clear in the documentation. Your link says nothing about modules. If I try go get it also fails: go get 192.168.0.12/gitrepo/go-module-test-dateutil@dev2 I have this in my ~/.gitconfig [url "[email protected]:"] I can use modules from my private repo as long as I do not include a branch specifier with @branchname. Adding @branchname to an entry in go.mo or with go get always fails. |
What
That seems to indicate that the server on |
GOPRIVATE and GOINSECURE are both unset. I've tried with GOPRIVATE="192.168.0.12/gitrepo/*" and it makes no difference. GOPRIVATE seems to have no effect at all. I can use modules from my private repos on github with GOPRIVATE unset. There is no web server on my server at 192.168.0.12. I'm accessing it via ssh. In my ~/.gitconfig [url "[email protected]:"] The issue arises when using a server with a non-routeable IP address via ssh. As long as I don't specify a branch name it also works. |
Note that that command is missing the
In that case, I'm not quite sure how it would be working in the first place. 😅 |
That was it
It made this change to the go.mod:
The tag v0.0.3 was on the last commit on the dev2 branch so one problem solved. But if I make another commit on the dev2 branch and run the same go get command to get that latest commit on dev2 it errors (GOPRIVATE is unset at this point): go get 192.168.0.12/gitrepo/go-module-test-dateutil.git@dev2 If I set GOPRIVATE it works: go env -w GOPRIVATE=192.168.0.12/gitrepo/* It made this change to go.mod:
So GOPRIVATE has to be set to pull a non-tagged last commit off of a branch, but apparently not if the last commit on the branch is tagged. The docs for GOPRIVATE aren't clear on what it does and when it does something. The @branchname should only be used with go get, not in a go.mod. The go.mod file has to contain a SemVer based on a tag or a pseudo-tag created by go get @branchname for the last commit on a branch. Thanks for helping me get this straightened out. The docs need to be clear about this and they are not. Can you change this to a documentation ticket to get this in the docs? |
Agreed. That's (part of) #41427. |
That's not how it's supposed to work. Here's a theory, though: perhaps you already had a checksum in your (That could be the case if, for example, you already depended on |
The The branch behavior is currently documented in Use of Use of The We still need proper tutorials for a lot of these things (in https://golang.org/doc/tutorial/); @stevetraut is actively working on those. |
Duplicate of #41427 |
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
)?GOHOSTARCH="amd64"
GOHOSTOS="linux"
Ubuntu 20.04
go env
OutputWhat did you do?
Note that I'm using a private server for my git repo. It was created with git init --bare. There is no web server, no github, no gitlab. I have ssh access with my public key and have modified my ~/.gitconfig appropriately. I can access modules as long as I specify a SemVer number, but if I want code from a branch other than master then go doesn't know how to parse the specified for the branch name or the commit hash.
I want to use a branch of a module In go.mod if I specify the branch name I get an error:
If I take out the space before the @ I get
I get the same errors if I use the commit hash of the last commit on the branch instead of the branch name.
What did you expect to see?
Should recognize that I'm specifying a branch name or commit hash
What did you see instead?
Parse errors on go.mod
If this is not the correct way to specify a branch or commit what is the correct syntax?
The text was updated successfully, but these errors were encountered: