go mod tidy "all" matched no packages [duplicate]

I've created a go module using this:

go mod init rtws vim main.go # pasted a bunch of code from an example go mod tidy 

Both of these files import "github.com/gorilla/websocket", so when I used tidy I expected that it would download that dependency, but instead I got the following warning:

go: warning: "all" matched no packages

And subsequently trying to run it complained that the dependency did not exist.
What does this error mean?

EDIT: when searching, the most relevant thing I found was this other question on SO. A lot of people had this warning come up when running other commands but their solutions didn't work for this particular situation.

0

1 Answer

I've found out what caused the issue while I was writing the question. At the top of the code that I pasted were the following lines:

//go:build ignore // +build ignore 

So, apparently this warning means there were no files in the module. The effect of the above lines tells go's build system to ignore that file, so go mod tidy behaved in the same way it would have if that file didn't exist.

Removing these allowed go mod tidy to do what I originally expected it to. Being new to golang this feature was not on the top of things I would have considered.

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobmtsaWeBc36OoKZmpZ%2BZerW1w7JkmqScYrqiwMKhnJ1lnqR6sa3CpJignaM%3D