I want to run the gopls analsysers on all the files in my project. I was hoping something like the following would work:
gopls check ./...
But unfortunately, "gopls check" only works with filenames and the ./... is for packages.
I really want to only check the files in each package in turn.
Usage: GOPLS_CHECK <PATH> [QUIET]
It works by finding all packages in the specified path and running an instance of "gopls check" for the files in each package. The number of "gopls check" running in parallel at any one time is limited to the number of CPU cores.
By default, the script will print out the names of the packages it is checking. This can be suppressed with the optional QUIET argument. When QUIET is set then only the output from gopls itself is printed.
Besides gopls, all commands should be available on any system with bash installed (xargs, dirname, etc.)
A simpler way of doing this would be to pass every file in the entire project to "gopls check" in one gulp. This didn't work well for me, seemingly because of the presence of build tags in some of my packages. The method described above works better for my purposes.
I'm posting because I thought that it might be useful to other people. I'm also curious if there are existing solutions. I was surprised at not being able to find an existing way to run the gopls analysers in this fashion.