go-tools icon indicating copy to clipboard operation
go-tools copied to clipboard

Make sure we support Go workspaces

Open dominikh opened this issue 3 years ago • 3 comments

dominikh avatar Feb 14 '22 22:02 dominikh

  • 1 here, any plans on supporting go workspaces?

smit2909 avatar Apr 11 '23 04:04 smit2909

I am not sure there is anything for us to do here. What is currently not working?

dominikh avatar Apr 11 '23 05:04 dominikh

I just converted a project from a single module...

/
| -- go.mod
| -- main.go
     | -- more_nested_directories/

...to a multi-module workspace....

/
| -- go.work
| -- modules/
     | -- mod_one
          | -- go.mod
          | -- main.go
          | -- more_nested_directories/
      | -- mod_two
          | -- go.mod
          | -- main.go
          | -- more_nested_directories/
// go.work
go 1.20

use (
	./modules/mod_one/
	./modules/mod_two/
)

The command that I previously used, i.e. staticcheck ./..., was now throwing the following error when invoked from the project root directory:

-: pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies (compile)

I couldn't figure out what the error is trying to tell me. What pattern other than ./... am I supposed to use?

The command that I am using now for the multi-module workspace is as follows:

go list -f '{{.Dir}}/...' -m | xargs staticcheck

I personally have no issues with using this command, but I think it would be nice if the documentation provided some guidance on what users should use in Go workspaces.

Environment

  • staticcheck v0.4.3
  • go 1.20.1 linux/amd64

samherrmann avatar May 24 '23 15:05 samherrmann