I am an absolute newbie to golang and I am sure this is a newbie question. But not finding a direct answer, I suspect it's not me.
How exactly does the repository part of the module path map to the URL? All examples on go.dev use github.com as the repository, but if I want to share a module I've written, it won't be on github. Is it possible to host it publicly elsewhere? (My non-golang projects are on sr.ht, which would be my first choice).
You can refer to the golang documentation at Remote Import Path, but I suspect, using the sr.ht you mentioned, You can write
import "git.sr.ht/~user/repo.git/path/to/module"
.git
tells go that it will look at the git repository. go will also try to use the https
protocol first, so no need to specify it.
The above is the detailed content of How to host public golang modules on github. For more information, please follow other related articles on the PHP Chinese website!