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.gowithgo build -o locatorServer main.go. - Execute
locatorServerwith the sitehostname, accessportandrepoLocation.- The
hostnameneeds 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
repoLocationis 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://[email protected]/team/go_module_.
- The
- If you use port 80, i.e.
http, you will need to set theGOINSECUREenvironment variable for your domain. ExGOINSECURE=mycooldomain.com. - Add this domain to the
GOPRIVATEenvironment 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://[email protected]/team/go_module_my_module.