Using Go Get with Repositories on Local Servers
Question:
How to use go get with a git repository hosted on a local server?
Answer:
Using Packages and Modules with Local Git Repositories
To use Go packages and modules with git repositories on private servers (IP addresses like 10.xxx.yyy.zzz or 192.168.xxx.yyy), follow these steps:
Prerequisites:
Setup:
package ├── github │ ├── dateutil │ │ └── src │ │ └── datepackage │ │ └── dateutil.go │ └── stringutil │ └── src │ └── stringpackage │ └── stringutil.go └── your-local-git-repo-hostname ├── dateutil │ └── src │ └── datepackage │ └── dateutil.go └── stringutil └── src └── stringpackage └── stringutil.go
Creating Repositories
git config --global url."[email protected]:".insteadOf "https://192.168.0.12/"
Using Git Repositories
Using go get
go get 192.168.0.12/gitrepo/go-package-test-stringutil.git/stringpackage go get 192.168.0.12/gitrepo/go-package-test-dateutil.git/datepackage
Key Differences:
When using repositories on a local server versus GitHub:
The above is the detailed content of How to Use `go get` with Locally Hosted Git Repositories?. For more information, please follow other related articles on the PHP Chinese website!