Specifying Ports in Remote Import Paths Using Go
Importing modules from private repositories located on a non-default port can be challenging in Go.
To specify a non-default port in a remote import path, add the port number after the protocol in the URL. For example:
import "http://example.com:8080/path/to/module"
However, the documentation does not explicitly mention this. Furthermore, simply adding the port number may result in compilation errors.
Alternative Solution: Modifying .gitconfig
An alternative solution involves modifying your .gitconfig file:
[url "[email protected]:6655"] insteadOf = git://internal-git.corporate-domain.com
By adding this configuration, you are mapping the non-default port to the specified protocol. This allows Go to correctly fetch modules from your private repository.
The above is the detailed content of How to Specify Non-Default Ports in Go's Remote Import Paths?. For more information, please follow other related articles on the PHP Chinese website!