'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



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jictyvoo