Interesting. If I put that go.mod file in an empty directory, then I see the warning:
$ go mod tidy
go: warning: "all" matched no packages
$ go mod tidy
go: warning: "all" matched no packages
> But when I run `go mod tidy`, it simply prints out the aforementioned warning and the new go.mod file looks like this
I see the same behaviour if I create a main.go file. Then the warning vanishes and the go.mod file is tidied:
$ mv main.go.x main.go
$ cat main.go
package main
func main() {
}
$ go mod tidy
$ cat go.mod
module module_name_obfuscated
go 1.17
$
This of course is expected behaviour: it's the job of go mod tidy to update the go.mod file so that it matches the source code in the module. See "go help mod tidy":
"Tidy makes sure go.mod matches the source code in the module.
It adds any missing modules necessary to build the current module's
packages and dependencies, and it removes unused modules that
don't provide any relevant packages."
So I presume the warning you see is only when go mod tidy can't find any source code in the current directory.