Reputation: 10303
I have a (private) github repo with a Go module. I've added the tag v0.1
and github shows that tag. I have set go env -w GOPRIVATE=github.com/dwschulze/key-value-mod
and my ~/.gitconfig has [url "[email protected]:"] insteadOf = https://github.com/
But go get
can't retrieve my module:
$ go get github.com/dwschulze/key-value-mod
go: github.com/dwschulze/key-value-mod upgrade => v0.0.0-20210907155619-9116b97467d6
go get: github.com/dwschulze/[email protected]: parsing go.mod:
module declares its path as: key-value-mod
but was required as: github.com/dwschulze/key-value-mod
$ go get github.com/dwschulze/[email protected]
go get github.com/dwschulze/[email protected]: no matching versions for query "v0.1"
What problem is go get
having?
Upvotes: 1
Views: 8567
Reputation: 10303
Two things were causing this. I had to clear my module cache. The second is as Simon mentions above the module name has to be the repo URL where the module will be published.
I don't like the close coupling that go modules have with source code repositories, but that is reality.
Upvotes: 2
Reputation: 22147
Your go modules semver of v0.1
is incorrect for go modules
consumption. It includes a major
version, minor
version - but is missing the patch
number:
Note: the Pre-release Identifier
suffix here (-beta.2
) is optional.
See also publishing go modules docs:
Every required module in a go.mod has a semantic version, the minimum version of that dependency to use to build the module.
A semantic version has the form vMAJOR.MINOR.PATCH.
So update your tag to v0.1.0
and it should work.
Upvotes: 2
Reputation: 96
Based on the error, I don't think you have any issues with the private repo. Rather, it seems to me that your go.mod
file declares the module as
module key-value-mod
...
while it should be
module github.com/dwschulze/key-value-mod
...
Upvotes: 2