Skip to content

Commit

Permalink
gopls: minor cleanup of standalone package support
Browse files Browse the repository at this point in the history
Remove an unused err value, and update tests to exercise multiple
standaloneTags.

Change-Id: I88daace99111cba6f8bc74fad8aa0db844cb2654
Reviewed-on: https://go-review.googlesource.com/c/tools/+/442776
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Findley <rfindley@google.com>
  • Loading branch information
findleyr authored and gopherbot committed Oct 19, 2022
1 parent 502b93c commit b50d7ba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions gopls/internal/lsp/cache/standalone_go116_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ func TestIsStandaloneFile(t *testing.T) {
[]string{"ignore"},
true,
},
{
"multiple tags",
"//go:build ignore\n\npackage main\n",
[]string{"exclude", "ignore"},
true,
},
{
"invalid tag",
"// +build ignore\n\npackage main\n",
Expand Down
2 changes: 1 addition & 1 deletion gopls/internal/lsp/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ func (s *Server) checkForOrphanedFile(ctx context.Context, snapshot source.Snaps
if snapshot.IsBuiltin(ctx, fh.URI()) {
return nil
}
pkgs, err := snapshot.PackagesForFile(ctx, fh.URI(), source.TypecheckWorkspace, false)
pkgs, _ := snapshot.PackagesForFile(ctx, fh.URI(), source.TypecheckWorkspace, false)
if len(pkgs) > 0 {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion gopls/internal/regtest/workspace/standalone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func main() {}

WithOptions(
Settings{
"standaloneTags": []string{"standalone"},
"standaloneTags": []string{"standalone", "script"},
},
).Run(t, files, func(t *testing.T, env *Env) {
env.OpenFile("ignore.go")
Expand Down

0 comments on commit b50d7ba

Please sign in to comment.