How to host public golang modules on github

PHPz
Release: 2024-02-06 08:39:04
forward
912 people have browsed it

如何在 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"
Copy after login

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

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template