Skip to content

Commit b50d7ba

Browse files
findleyrgopherbot
authored andcommitted
gopls: minor cleanup of standalone package support
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 <[email protected]> gopls-CI: kokoro <[email protected]> Reviewed-by: Alan Donovan <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Robert Findley <[email protected]>
1 parent 502b93c commit b50d7ba

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

gopls/internal/lsp/cache/standalone_go116_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ func TestIsStandaloneFile(t *testing.T) {
3030
[]string{"ignore"},
3131
true,
3232
},
33+
{
34+
"multiple tags",
35+
"//go:build ignore\n\npackage main\n",
36+
[]string{"exclude", "ignore"},
37+
true,
38+
},
3339
{
3440
"invalid tag",
3541
"// +build ignore\n\npackage main\n",

gopls/internal/lsp/diagnostics.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ func (s *Server) checkForOrphanedFile(ctx context.Context, snapshot source.Snaps
534534
if snapshot.IsBuiltin(ctx, fh.URI()) {
535535
return nil
536536
}
537-
pkgs, err := snapshot.PackagesForFile(ctx, fh.URI(), source.TypecheckWorkspace, false)
537+
pkgs, _ := snapshot.PackagesForFile(ctx, fh.URI(), source.TypecheckWorkspace, false)
538538
if len(pkgs) > 0 {
539539
return nil
540540
}

gopls/internal/regtest/workspace/standalone_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func main() {}
214214

215215
WithOptions(
216216
Settings{
217-
"standaloneTags": []string{"standalone"},
217+
"standaloneTags": []string{"standalone", "script"},
218218
},
219219
).Run(t, files, func(t *testing.T, env *Env) {
220220
env.OpenFile("ignore.go")

0 commit comments

Comments
 (0)