You’re not stuck. You just need to add printlns!
Sometimes you get a cryptic error message when you “go build” like:
go: github.com/private-repo/lib-golang_thing-common@v1.2.2: reading github.com/private-repo/lib-golang_thing-common/go.mod at revision v1.2.2: unknown revision v1.2.2
And there just isn’t the -v or -vv or -vvv verbose debug option you need.
Time to goto the source.
First step, grep for the string “unknown revision”.
go-src/src $ grep -R "unknown revision" .
./cmd/go/internal/modfetch/codehost/codehost.go: return "unknown revision " + e.Rev
Next step, lets change that error message slighty to prove I’ve found the right place. I added an explanation point to the string:
"unknown revision! " + e.Rev
And pure joy after it compiles go, and my go build now shows me this error WITH the new explanation point. That means I’m in. I have control now of what it will print as I trace further up the source from this line.
I keep adding fmt.Println(“got here!”) all over the place. I can now create my own -vvv verbose mode with anything I want.
I find myself deep inside some func called “loadRefs” with this nice hint:
rerr.HelpText = "If this is a private repository, see https://golang.org/doc/faq#git_https for additional information."
Is my thing a private repository? Why yes it is. Turns out I was missing:
[url "ssh://git@github.com/"] insteadOf = https://github.com/
in ~/.gitconfig
This blog post brought to you by programmers that say, “I’m stuck.” You’re not stuck. You just need to add printlns!