This is a very simple web server used to provide go mod
with the location of your private Go module. This
is useful when your private Go modules are accessed via non-standard ports.
- Build
main.go
withgo build -o locatorServer main.go
. - Execute
locatorServer
with the sitehostname
, accessport
andrepoLocation
.- The
hostname
needs to be the same as in your go module. - If you are running the server locally, you can point the hostname to you localhost ip by editing
/etc/hosts
. - The
repoLocation
is where you will be pulling your Go module from via git. Example, if all your Go module repos are namedgo_module_<module_name>
, you can set this tossh://git@company.com/team/go_module_
.
- The
- If you use port 80, i.e.
http
, you will need to set theGOINSECURE
environment variable for your domain. ExGOINSECURE=mycooldomain.com
. - Add this domain to the
GOPRIVATE
environment variable to avoid sum checks.
Once running, when go wants to access one of your private Go modules, example
import (
myModule "mycooldomain.com/my_module"
)
go will send a GET request to https://mycooldomain.com/my_module
and the server will tell go mod to git pull the repo
from <repoLocation><module_name>
, i.e. ssh://git@company.com/team/go_module_my_module
.