4
4
"fmt"
5
5
"os"
6
6
"path/filepath"
7
- "strings"
8
7
)
9
8
10
9
// Unique eliminates the duplicate paths from the provided slice and returns
@@ -52,7 +51,6 @@ func First(paths []string) string {
52
51
// relative to the selected parent path.
53
52
func Create (name string , paths []string ) (string , error ) {
54
53
searchedPaths := make ([]string , 0 , len (paths ))
55
-
56
54
for _ , p := range paths {
57
55
p = filepath .Join (p , name )
58
56
@@ -67,16 +65,15 @@ func Create(name string, paths []string) (string, error) {
67
65
searchedPaths = append (searchedPaths , dir )
68
66
}
69
67
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 )
72
70
}
73
71
74
72
// Search searches for the file with the specified `name` in the provided
75
73
// slice of `paths`. The `name` parameter must contain the name of the file,
76
74
// but it can also contain a set of parent directories.
77
75
func Search (name string , paths []string ) (string , error ) {
78
76
searchedPaths := make ([]string , 0 , len (paths ))
79
-
80
77
for _ , p := range paths {
81
78
p = filepath .Join (p , name )
82
79
if Exists (p ) {
@@ -86,8 +83,8 @@ func Search(name string, paths []string) (string, error) {
86
83
searchedPaths = append (searchedPaths , filepath .Dir (p ))
87
84
}
88
85
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 )
91
88
}
92
89
93
90
// EnvPath returns the value of the environment variable with the specified
0 commit comments