giturlsshconfiggo-get

the git.config of setting url doesn't work


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@email.com
[difftool "sourcetree"]
    cmd = '' \"$LOCAL\" \"$REMOTE\"
[mergetool "sourcetree"]
    cmd = "'' "
    trustExitCode = true
[url "ssh://git@origin.url: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.


Solution

  • 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?