Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot install vet package with go get

Tags:

go

I'm running following command:

$ go get -u golang.org/x/tools/cmd/vet

package golang.org/x/tools/cmd/vet: cannot find package "golang.org/x/tools/cmd/vet" in any of: C:\Development\Software\go\src\golang.org\x\tools\cmd\vet (from $GOROOT)
C:\Development\Software\go\downloaded_packages\src\golang.org\x\tools\cmd\vet (from $GOPATH)

I can't really understand how cannot find package makes sense with get. It is supposed to get the package from internet. Why is it looking for it locally?

like image 668
Kshitiz Sharma Avatar asked Jun 10 '16 19:06

Kshitiz Sharma


People also ask

What is go vet command?

Go vet command is a great help while writing your code. It helps you detect any suspicious, abnormal, or useless code in your application. The command is actually composed of several sub analyzers and could even work with your custom analyzer.

How do I install packages in go?

To install a package using go get follow the following steps: Step 1: Make sure to check whether the Golang is installed on your system by checking the version of Go. Step 2: Set the GOPATH by using the following command. Step 3: Now, set the PATH variable with the help of the following command.


1 Answers

@JimB summed it up in the comments - you don't need to install go vet separately.

But just for completeness, the direct answer to OP question is that the code for the go vet command no longer lives at golang.org/x/tools/cmd/vet (see https://golang.org/doc/go1.2#go_tools_godoc - and since that the code has moved to GitHub).

So when you run: go get -u golang.org/x/tools/cmd/vet it appears that it is git cloning the golang.org/x/tools/cmd package and then trying to compile golang.org/x/tools/cmd/vet which is resulting in an error ("cannot find package...") because the "vet" part doesn't exist - it moved out a while ago. (go get first downloads/clones the code and then attempts to compile the package on your local system.)

And all of that is to say, you probably already have go vet - try typing "go vet -h" and if it works (you should see something like: "usage: vet ..."), you're set.

like image 51
Brad Peabody Avatar answered Nov 15 '22 09:11

Brad Peabody