简体   繁体   中英

unable to get go package from private github repository

Had this working perfectly before I had my computer refreshed, now I now am unable to pull packages from my orgs private github repository. At this time I only need an ssh private key to clone the repository, i am not aware of any 2fA requirement. I have spent hours already trying to resolve this, from what i read this is what I think should work, omitting sensitive variable values.

Error i was getting was unknown versions, but I changed some stuff and now i am getting "ssh: Could not resolve hostname".

    #!/bin/bash
    export GOPATH="$HOME/go"
    export GOBIN="$HOME/go/bin"
    export GOPRIVATE="github.com/${GITHUB_ORG}"
    
    go env -w GO111MODULE="on"
    go env -w GOPRIVATE="github.com/${GITHUB_ORG}"
    
    git config --global url."git@github.com:".insteadOf "https://github.com/"
    
    pushd ~/.ssh
       eval $(ssh-agent);
       ssh-add "${GITHUB_PRIVATE_KEY_PATH}"
    popd
    
    go get package "github.com/${GITHUB_ORG}/${GITHUB_REPO}/${GO_PACKAGE}"

You can try by changing git to use ssh instead of https so that you can fetch private go repositories using go get .

Suggestion -

git config --global url.ssh://git@github.com/.insteadOf https://github.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM