This forum won’t let write a github URL several times, so I have removed the dot-com in the following.
I’m fairly new to GO, but have been A Computer Guy for decades. I am mystified by the following error:
I have a go module that imports another package of mine called ‘hdump’. It worked fine when it was a local module (available via “…/hdump”). But then I moved it to github. Then when I changed the import to reference “github/tgphelps/hdump”, and do a “go mod tidy”, I get:
$ go mod tidy
go: github/tgphelps/hdump@v0.0.1: parsing go.mod:
module declares its path as: githum/tgphelps/hdump
but was required as: github/tgphelps/hdump
You can look at go.mod at github/tgphelps/hdump and see that it does NOT declare itself in that way (as “githum”, not “github”). I have been fighting with this all day, and can’t see what’s wrong. There maybe have been a time in the past where the hdump module on github had that error in it, possibly, but to make sure that was gone, I removed that github repo, verified that the go.mod was right, and created another github/tgphelps/hdump that doesn’t say “githum” ANYwhere. But I’m still getting that error! How can that happen?
Did you possibly declare the module indeed as githum.com/... and corrected that typo later?
If so, the typo might still be cached at the Go module proxy server.
→ Try pushing a new version number (e.g. v0.0.2) to GitHub and then do a go get github.com/tgphelps/hdump@v0.0.2 (or go get github.com/tgphelps/hdump@latest).
(BTW, quick tip: use backticks to mark text as code, and use a line with three backticks to start and end a code block. This way, URL’s should not pose a problem anymore in the forum editor.)
(Thanks for the backtick tip. I edited the post to make it look much better.)
Yes, it’s quite possible that I had a typo (githum.com) at one time, but I can’t say either way. Could that typo stay cached in the Go module proxy server for months? It’s been that long since I originally created that repo.
I will do as you recommend, and push a new version. (I am new to this. By “push a new version”, I assume you mean make a new git tag, v0.0.2.)
Yes, that’s what I meant… but OTOH none of the commits in the GitHub repo shows a go.mod where the module path starts with githum. I wonder how and where the wrong spelling then crept in (and out again)
Well…as I mentioned in the original post, earlier today, in an attempt to get around this, I deleted the original hdump repo on Github, and created a new one (with the same name), so it is quite possible that, at some time in the past, there was a commit with the typo in the go.mod file.
I guess there’s no way to clear out a cached copy in the proxy server, huh? Tomorrow, I’ll create a new version and try again.
You have added much to my knowledge of how go modules work. Thank you for being patient with a newcomer.
It took me a while to catch onto what “remember left-pad” meant. Yes, I see the relevance.
I didn’t know about ‘retract’, either.
Your suggestion (push a new version) did indeed fix the problem. It all makes sense once one learns that there is such a thing as a proxy server. My reading had missed that detail.
The proxy server is a bit tricky because it works so smoothly and transparently that it is completely invisible in daily operation. Thus if a module-related error pops up, the proxy is usually the last thing to think of.