如何从Gitea进行`go install`操作?

huangapple go评论66阅读模式
英文:

how to `go install` from gitea

问题

我正在尝试从一个自托管的 Gitea 实例安装一个包。我正在尝试运行 go install gitea.urkob.com/urko/go-root-dir,但是我遇到了以下错误:

no required module provides package gitea.urkob.com/urko/go-root-dir; to add it:
        go get gitea.urkob.com/urko/go-root-dir

如果能帮助我配置我的 go 环境,我将不胜感激。

我已经设置了 GOPRIVATE="gitea.urkob.com/urko",但它仍然不起作用,我不知道是否漏掉了什么。

英文:

I'm trying to install a package from a self-hosted gitea instance. I'm trying to get a package running go install gitea.urkob.com/urko/go-root-dir but I'm getting this error

no required module provides package gitea.urkob.com/urko/go-root-dir; to add it:
        go get gitea.urkob.com/urko/go-root-dir

Any help would be appreciated to show me how can I configure my go env.

I've set GOPRIVATE="gitea.urkob.com/urko" but it still not working, I don't know if I'm missing something.

答案1

得分: 0

go install 用于安装二进制文件,而不是包。

而在你的情况下,gitea.urkob.com/urko/go-root-dir 只是一个包,因为当我尝试使用 go get 时,我得到的结果是:

$ go get -v gitea.urkob.com/urko/go-root-dir
get "gitea.urkob.com/urko/go-root-dir": found meta tag vcs.metaImport{Prefix:"gitea.urkob.com/urko/go-root-dir", VCS:"git", RepoRoot:"https://gitea.urkob.com/urko/go-root-dir.git"} at //gitea.urkob.com/urko/go-root-dir?go-get=1
gitea.urkob.com/urko/go-root-dir (download)
gitea.urkob.com/urko/go-root-dir
# gitea.urkob.com/urko/go-root-dir
runtime.main_main·f: function main is undeclared in the main package

如果你希望它是一个二进制文件,请为其添加/指定一个 main 函数。

英文:

go install is used to install a binary, not a package.

Whereas in your case, gitea.urkob.com/urko/go-root-dir is only a package, because when I tried with go get, I'm getting:

$ go get -v gitea.urkob.com/urko/go-root-dir
get "gitea.urkob.com/urko/go-root-dir": found meta tag vcs.metaImport{Prefix:"gitea.urkob.com/urko/go-root-dir", VCS:"git", RepoRoot:"https://gitea.urkob.com/urko/go-root-dir.git"} at //gitea.urkob.com/urko/go-root-dir?go-get=1
gitea.urkob.com/urko/go-root-dir (download)
gitea.urkob.com/urko/go-root-dir
# gitea.urkob.com/urko/go-root-dir
runtime.main_main·f: function main is undeclared in the main package

If you meant it to be a binary, then put/specify a main function for it.

huangapple
  • 本文由 发表于 2023年2月26日 17:07:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/75570970.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定