Skip to content

Commit 80e2c2e

Browse files
committed
Refactored commaSeparatedToList function
1 parent ef57e49 commit 80e2c2e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Diff for: arduino/libraries/loader.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ func makeNewLibrary(libraryDir *paths.Path, location LibraryLocation) (*Library,
5656
}
5757
}
5858

59+
commaSeparatedToList := func(in string) []string {
60+
res := []string{}
61+
for _, e := range strings.Split(in, ",") {
62+
res = append(res, strings.TrimSpace(e))
63+
}
64+
return res
65+
}
66+
5967
library := &Library{}
6068
library.Location = location
6169
library.InstallDir = libraryDir
@@ -71,10 +79,7 @@ func makeNewLibrary(libraryDir *paths.Path, location LibraryLocation) (*Library,
7179
if libProperties.Get("architectures") == "" {
7280
libProperties.Set("architectures", "*")
7381
}
74-
library.Architectures = []string{}
75-
for _, arch := range strings.Split(libProperties.Get("architectures"), ",") {
76-
library.Architectures = append(library.Architectures, strings.TrimSpace(arch))
77-
}
82+
library.Architectures = commaSeparatedToList(libProperties.Get("architectures"))
7883

7984
libProperties.Set("category", strings.TrimSpace(libProperties.Get("category")))
8085
if !ValidCategories[libProperties.Get("category")] {

0 commit comments

Comments
 (0)