Reputation: 289
I met a weird bugs. For somereason, I need to get a library from ssh, instead of https:// And I think I set up the .gitconfig correct.
Here is my .gitconfig:
[user]
name = nickName
email = [email protected]
[difftool "sourcetree"]
cmd = '' \"$LOCAL\" \"$REMOTE\"
[mergetool "sourcetree"]
cmd = "'' "
trustExitCode = true
[url "ssh://[email protected]:7999/"]
insteadOf = https://url/scm
However, when I run go get url/lirbaryName
It's throw me the error said can't get the library from www....., it looks that the go get still trying to download the library from https:// not ssh:. Here is the error message.
go: url/lirbaryName@versionnumber/go.mod: verifying module: url/lirbaryName@versionnumber/go.mod: reading https://sum.golang.org/lookup/url/lirbaryName@versionnumber: 410 Gone
server response:
not found: wurl/lirbaryName@versionnumber: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/gopath/pkg/mod/cache/vcs/7f429b03663193143b68514b6b1945024c80ec1d9b17c4afa862b0b8304a9db8: exit status 128:
fatal: could not read Username for 'https://url': terminal prompts disabled
Any idea for the bug? My go version is 1.15, and this library is not broken, my friend can go get successful with the same git config. By the way, I can git clone this library to the go/src folder, and run go build and go install, unfortunately, it's not working. still can't use this library in the go program.
let me know if you need more info. Thank you for the help.
Upvotes: 1
Views: 1846
Reputation: 289
I close this issue by exampling how I fix this issue. I have checked the git env and go env. Everything looks good for me. So finally I can use go get -v url/lirbaryName to download successful. However go get url/lirbaryName still doesn't work for me. I don't understand why, but magically it works for me now. Any one has the clue?
Upvotes: 0
Reputation: 1456
go get disables the "terminal prompt" by default. This can be changed by setting an environment variable of git:
env GIT_TERMINAL_PROMPT=1 go get url/lirbaryName
or change git like as below,
git config --global --add url."[email protected]:".insteadOf "https://github.com/"
Upvotes: 1
Reputation: 1324737
If your friend manage to go get the repository through SSH using a similar configuration, you need to double for any difference between:
go env
and your friend's go env
"How can I make go get work with a repo on a local server" describe the same kind of git config --global url.ssh://[email protected]:7999/".InsteadOf "https://xxx
technique, so it should work.
But it does point out:
To use modules with private repos we have to set
GOPRIVATE
go env -w GOPRIVATE=origin.url/*
When
GOPRIVATE
is set, modules will be pulled directly from the specified git repos instead of the Go public proxy.
That could be one example of possible difference between your environment and your friend's.
Upvotes: 0