JoaoDaniel Rufino
JoaoDaniel Rufino

Reputation: 77

go install @latest found but does not contain package

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

Upvotes: 5

Views: 13828

Answers (3)

steven shen
steven shen

Reputation: 1

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

Upvotes: 0

Moses Tapfuma
Moses Tapfuma

Reputation: 31

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

Upvotes: 1

Jictyvoo
Jictyvoo

Reputation: 88

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

Upvotes: 5

Related Questions