Skip to content

Commit

Permalink
go/pacakges: remove some todos
Browse files Browse the repository at this point in the history
* use std slices.Clip
* remove outdated check as the original issue was fixed

Change-Id: Ie54b202ecabc3318a4f20772fd62bd63542f8237
Reviewed-on: https://go-review.googlesource.com/c/tools/+/626416
Reviewed-by: Michael Matloob <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Alan Donovan <[email protected]>
Reviewed-by: Alan Donovan <[email protected]>
  • Loading branch information
xieyuschen authored and matloob committed Nov 11, 2024
1 parent 69c27ad commit fd8d028
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
7 changes: 2 additions & 5 deletions go/packages/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"fmt"
"os"
"os/exec"
"slices"
"strings"
)

Expand Down Expand Up @@ -131,7 +132,7 @@ func findExternalDriver(cfg *Config) driver {
// command.
//
// (See similar trick in Invocation.run in ../../internal/gocommand/invoke.go)
cmd.Env = append(slicesClip(cfg.Env), "PWD="+cfg.Dir)
cmd.Env = append(slices.Clip(cfg.Env), "PWD="+cfg.Dir)
cmd.Stdin = bytes.NewReader(req)
cmd.Stdout = buf
cmd.Stderr = stderr
Expand All @@ -150,7 +151,3 @@ func findExternalDriver(cfg *Config) driver {
return &response, nil
}
}

// slicesClip removes unused capacity from the slice, returning s[:len(s):len(s)].
// TODO(adonovan): use go1.21 slices.Clip.
func slicesClip[S ~[]E, E any](s S) S { return s[:len(s):len(s)] }
5 changes: 0 additions & 5 deletions go/packages/packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,6 @@ func testConfigDir(t *testing.T, exporter packagestest.Exporter) {
test.dir, test.pattern, got, test.want)
}
if fails != test.fails {
// TODO: remove when go#28023 is fixed
if test.fails && strings.HasPrefix(test.pattern, "./") && exporter == packagestest.Modules {
// Currently go list in module mode does not handle missing directories correctly.
continue
}
t.Errorf("dir %q, pattern %q: error %v, want %v",
test.dir, test.pattern, fails, test.fails)
}
Expand Down

0 comments on commit fd8d028

Please sign in to comment.