英文:
How to host a public golang module not on github
问题
我是一个绝对的Go语言新手,我确定这是一个新手问题。但是我找不到一个直接的答案,而且我怀疑不是我的问题。
模块路径的存储库部分如何映射到URL?所有在go.dev上的示例都使用github.com作为存储库,但是如果我想分享我编写的模块,它将不会在github上。是否有可能在其他地方公开托管?(我的非Go语言项目在sr.ht上,那将是我的首选)。
英文:
I'm an absolute newbie in golang, and I'm sure this is a newbie question. But having no luck finding a straight answer, and I suspect it is not me.
How exactly does the repository part of a module path map to an URL? All the examples on go.dev use github.com as the repository, but if I ever want to share a module I write, it won't be on github. Is it possible at all to publicly host elsewhere? (My non-golang projects are on sr.ht, and that would be my first choice).
答案1
得分: 0
你可以参考golang文档中的远程导入路径,但我怀疑,根据你提到的sr.ht,你可以直接写成:
import "git.sr.ht/~user/repo.git/path/to/module"
.git
告诉go它将查找一个git仓库。Go还会尝试首先使用https
协议,所以不需要指定。
英文:
You can reference to golang docs at remote import paths, but I suspect, using your mention of sr.ht, you can just write
import "git.sr.ht/~user/repo.git/path/to/module"
The .git
tells go that it will be looking at a git repository. Go will also try to use the https
protocol first, so that does not need to specified.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论