Home  >  Article  >  Backend Development  >  How to host public golang modules on github

How to host public golang modules on github

PHPz
PHPzforward
2024-02-06 08:39:04894browse

如何在 github 上托管公共 golang 模块

Question content

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).


Correct Answer


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!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete