英文:
go install @latest found but does not contain package
问题
我正在尝试使用go install
安装我的包,但是当运行命令go install github.com/JoaoDanielRufino/gcloc/cmd/gcloc@latest
时,我收到了以下错误信息:
go install: github.com/JoaoDanielRufino/gcloc/cmd/gcloc@latest: 模块 github.com/JoaoDanielRufino/gcloc@latest 找到(v1.0.0),但不包含包 github.com/JoaoDanielRufino/gcloc/cmd/gcloc
我希望可执行文件的名称为gcloc
。
这是当前的源代码:https://github.com/JoaoDanielRufino/gcloc
注意:我已经尝试过go clean -modcache
,但没有起作用。
英文:
I'm trying to install my package using go install
but I get this error message when running the command go install github.com/JoaoDanielRufino/gcloc/cmd/gcloc@latest
:
go install: github.com/JoaoDanielRufino/gcloc/cmd/gcloc@latest: module github.com/JoaoDanielRufino/gcloc@latest found (v1.0.0), but does not contain package github.com/JoaoDanielRufino/gcloc/cmd/gcloc
I want the executable name to be gcloc
.
Here is the current source code: https://github.com/JoaoDanielRufino/gcloc
Note: I've already tried go clean -modcache
but it didn't work
答案1
得分: 3
作为该软件包的主要功能不在其根目录上,您应该在命令中传递 main
软件包的目录。
因此,您的命令将是:
go install -v github.com/JoaoDanielRufino/gcloc/cmd@latest
英文:
As the main function of this package isn't on its root, you should pass the directory of the main
package on your command.
So, your command will be:
go install -v github.com/JoaoDanielRufino/gcloc/cmd@latest
答案2
得分: 1
我在尝试在我的机器上使用go install安装cloudflare/cf-terraforming工具时遇到了类似的问题。该工具的文档对安装过程不够清晰,我不得不进行一番搜索才能使其正常工作。
基本上,@Jictyvoo上面的答案总结得很好,如果路径指向的不是main.go文件所在的目录,我就会遇到错误。
命令:go install github.com/cloudflare/cf-terraforming@latest v0.8.0@latest
> go: github.com/cloudflare/cf-terraforming@latest: 模块
> github.com/cloudflare/cf-terraforming@latest 找到(v0.8.0),但不包含
> 包 github.com/cloudflare/cf-terraforming
当我改用下面的命令时,它对我来说正常工作了:
命令:go install -v github.com/cloudflare/cf-terraforming/cmd/cf-terraforming@latest
在检查了存储库并意识到main.go文件位于cmd/cf-terraforming子目录中后,这对我起作用了。
英文:
I came across a similar issue when I was trying to use go install to install the cloudflare/cf-terraforming tool on my machine. The documentation for this tool is not clear on the installation and I had to dig around to get this to work
Basically @Jictyvoo answer above sums it up, if the path is pointing to anything other than directory where the main.go file is sitting I got the error
Command: go install github.com/cloudflare/cf-terraforming@latest v0.8.0@latest
> go: github.com/cloudflare/cf-terraforming@latest: module
> github.com/cloudflare/cf-terraforming@latest found (v0.8.0), but does not
> contain package github.com/cloudflare/cf-terraforming
when I switched to the below it worked fine for me:
Command: go install -v github.com/cloudflare/cf-terraforming/cmd/cf-terraforming@latest
This worked for me after checking the repo and realising that the main.go file was sitting in the cmd/cf-terraforming subdirectory
答案3
得分: 0
我在安装"golang.org/x/mobile"时遇到了与你类似的问题。我从浏览器点击它,跳转到https://pkg.go.dev/golang.org/x/mobile
,我尝试了所有可能的命令,但显然没有起作用。
顺便说一下,我的本地环境中有GOPROXY="https://proxy.golang.org,direct"。
go.mod可以导入和下载相同的资源,但当我使用"go install"时,出现了一些问题。
英文:
I came across a similar issue like you did when I install "golang.org/x/mobile" , i click it from browser and jump to https://pkg.go.dev/golang.org/x/mobile
, i try to every command I can , but is not work apparently.
by the way ,the env of my localhost have that GOPROXY="https://proxy.golang.org,direct"
the go.mod can import and download the same resource , but when I use "go install ", something is wrong
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论