How can I make go get work with a repo on a local server?
Go get doesn't work with repos on a local server by default. To make it work, you need to add the following line to your ~/.gitconfig file:
[url "<User>@<hostname>:<ssh-port>/<path-to-repo>.git"] insteadOf = https://<user>@<hostname>:<ssh-port>/<path-to-repo>.git
Replace
For example, if your username is John Doe, your server's hostname is example.com, your SSH port number is 22, and your repo is located at /home/John Doe/my-repo, you would add the following line to your ~/.gitconfig file:
[url "John Doe@example.com:22/home/John Doe/my-repo.git"] insteadOf = https://John Doe@example.com:22/home/John Doe/my-repo.git
Once you have added this line to your ~/.gitconfig file, you should be able to use go get to fetch repos from your local server.
Example
To clone a repo from a local server with go get, you can use the following command:
go get git@<hostname>:<user>/<repo>.git
Replace
For example, to clone the 'my-repo' repo from the 'example.com' server using the 'John Doe' user, you would use the following command:
go get git@example.com:John Doe/my-repo.git
This command will clone the 'my-repo' repo into the 'my-repo' directory in your GOPATH.
The above is the detailed content of How to Make `go get` Work with a Local Server Repository?. For more information, please follow other related articles on the PHP Chinese website!