Customizing Remote Import Paths with Non-Default Ports in Go
When working with private git repositories that deviate from the standard HTTP port (e.g., 6655), specifying the port in the remote import path becomes crucial. However, this can pose a challenge in Go, as the documentation does not explicitly address port specification.
Consider the following scenario where a private git repository, "internal-git.corporate-domain.com," listens on port 6655 and contains a Go library named "golang-lib.git." Importing this library would typically involve:
import "internal-git.corporate-domain.com:6655/~myuser/golang-lib.git"
However, this approach yields an error: "invalid import path."
An alternative solution is to modify the ".gitconfig" file to accommodate ports:
[url "[email protected]:6655"] insteadOf = git://internal-git.corporate-domain.com
By specifying the port in the URL section of ".gitconfig," the custom path can be used without encountering import errors.
The above is the detailed content of How to Import Go Packages from Private Git Repositories Using Non-Standard Ports?. For more information, please follow other related articles on the PHP Chinese website!