Skip to content

Commit 42b45f7

Browse files
authored
fix: display the real Go commands (#54)
1 parent e1722a5 commit 42b45f7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

utils.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ func mainModule() (dir string, packages map[string]struct{}, _ error) {
1616
// especially on macOS, which has the default soft limit set to 256 (ulimit -nS).
1717
// Since go1.19 the limit is automatically increased to the maximum allowed value;
1818
// see https://github.com/golang/go/issues/46279 for details.
19-
cmd := [...]string{"go", "list", "-f={{if and (not .Standard) .Module.Main}}{{.ImportPath}}{{end}}", "all"}
19+
args := []string{"go", "list", "-f={{if and (not .Standard) .Module.Main}}{{.ImportPath}}{{end}}", "all"}
2020

21-
out, err := exec.Command(cmd[0], cmd[1:]...).Output()
21+
out, err := exec.Command(args[0], args[1:]...).Output()
2222
if err != nil {
23-
return "", nil, fmt.Errorf("running `go list all`: %w", err)
23+
return "", nil, fmt.Errorf("running `%s`: %w", strings.Join(args, " "), err)
2424
}
2525

2626
list := strings.Split(strings.TrimSpace(string(out)), "\n")
@@ -31,9 +31,10 @@ func mainModule() (dir string, packages map[string]struct{}, _ error) {
3131
packages[pkg+"_test"] = struct{}{} // `*_test` packages belong to the main module, see issue #24.
3232
}
3333

34-
out, err = exec.Command("go", "list", "-m", "-f={{.Dir}}").Output()
34+
args = []string{"go", "list", "-m", "-f={{.Dir}}"}
35+
out, err = exec.Command(args[0], args[1:]...).Output()
3536
if err != nil {
36-
return "", nil, fmt.Errorf("running `go list -m`: %w", err)
37+
return "", nil, fmt.Errorf("running `%s`: %w", strings.Join(args, " "), err)
3738
}
3839

3940
dir = strings.TrimSpace(string(out))

0 commit comments

Comments
 (0)