简体   繁体   中英

Using go get to retrieve from a local repository and private repo

Hi my goal is to have go get retrieve from a private repo on github.

The problem I am having is that I am committing into a folder structure that is outside of my GOPATH. So I want to test that what I have works before I commit.

1) How do I make go get retrieve from a local directory that is outside my path. Say my go code is in a directory $HOME/project/ How can I tell go get to retrieve the package and place it in the appropriate github.com folder structure so that my package references work?

2) How can I use go get to pull from a private repo? Should it just ask for my username and password?

You cannot do neither 1) nor 2) (easily). go get is not intended to be used this way.

  1. This is not really possible without serious hacks. The "simplest" hack is probably using a symlink, bind mount, or NFS mount.

    That being said, it's best to just follow GOPATH . You don't have to like it, but for better or worse Go is opinionated about these sort of things, and your life will be easier.

  2. Use ssh keys for authorisation (rather than a user/password) and add this to your ~/.gitconfig to make sure ssh is used:

     [url "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