Skip to content

Commit 9bbb602

Browse files
committed
Minor error format improvement in pathutil.Create and pathutil.Search
1 parent 987b3ce commit 9bbb602

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

internal/pathutil/pathutil.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"os"
66
"path/filepath"
7-
"strings"
87
)
98

109
// Unique eliminates the duplicate paths from the provided slice and returns
@@ -52,7 +51,6 @@ func First(paths []string) string {
5251
// relative to the selected parent path.
5352
func Create(name string, paths []string) (string, error) {
5453
searchedPaths := make([]string, 0, len(paths))
55-
5654
for _, p := range paths {
5755
p = filepath.Join(p, name)
5856

@@ -67,16 +65,15 @@ func Create(name string, paths []string) (string, error) {
6765
searchedPaths = append(searchedPaths, dir)
6866
}
6967

70-
return "", fmt.Errorf("could not create any of the following paths: %s",
71-
strings.Join(searchedPaths, ", "))
68+
return "", fmt.Errorf("could not create any of the following paths: %v",
69+
searchedPaths)
7270
}
7371

7472
// Search searches for the file with the specified `name` in the provided
7573
// slice of `paths`. The `name` parameter must contain the name of the file,
7674
// but it can also contain a set of parent directories.
7775
func Search(name string, paths []string) (string, error) {
7876
searchedPaths := make([]string, 0, len(paths))
79-
8077
for _, p := range paths {
8178
p = filepath.Join(p, name)
8279
if Exists(p) {
@@ -86,8 +83,8 @@ func Search(name string, paths []string) (string, error) {
8683
searchedPaths = append(searchedPaths, filepath.Dir(p))
8784
}
8885

89-
return "", fmt.Errorf("could not locate `%s` in any of the following paths: %s",
90-
filepath.Base(name), strings.Join(searchedPaths, ", "))
86+
return "", fmt.Errorf("could not locate `%s` in any of the following paths: %v",
87+
filepath.Base(name), searchedPaths)
9188
}
9289

9390
// EnvPath returns the value of the environment variable with the specified

0 commit comments

Comments
 (0)