Skip to content

Commit dbbced5

Browse files
committed
Simplified os-env management
1 parent 936a6e6 commit dbbced5

File tree

2 files changed

+4
-27
lines changed

2 files changed

+4
-27
lines changed

internal/libraries/clamav.go

+1-25
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,10 @@ import (
3030
"strings"
3131
)
3232

33-
func envSliceToMap(env []string) map[string]string {
34-
envMap := make(map[string]string)
35-
for _, value := range env {
36-
key := value[:strings.Index(value, "=")]
37-
value = value[strings.Index(value, "=")+1:]
38-
envMap[key] = value
39-
}
40-
return envMap
41-
}
42-
43-
func envMapToSlice(envMap map[string]string) []string {
44-
var env []string
45-
for key, value := range envMap {
46-
env = append(env, key+"="+value)
47-
}
48-
return env
49-
}
50-
51-
func modifyEnv(env []string, key, value string) []string {
52-
envMap := envSliceToMap(env)
53-
envMap[key] = value
54-
return envMapToSlice(envMap)
55-
}
56-
5733
// RunAntiVirus scans the folder for viruses.
5834
func RunAntiVirus(folder string) ([]byte, error) {
5935
cmd := exec.Command("clamdscan", "--fdpass", "-i", folder)
60-
cmd.Env = modifyEnv(os.Environ(), "LANG", "en")
36+
cmd.Env = append(os.Environ(), "LANG=en")
6137

6238
out, err := cmd.CombinedOutput()
6339
if err != nil {

internal/libraries/lint.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ func RunArduinoLint(arduinoLintPath string, folder string, metadata *Repo) ([]by
7272
folder,
7373
)
7474
// See: https://arduino.github.io/arduino-lint/latest/#environment-variables
75-
cmd.Env = modifyEnv(os.Environ(), "ARDUINO_LINT_LIBRARY_MANAGER_INDEXING", "true")
76-
cmd.Env = modifyEnv(cmd.Env, "ARDUINO_LINT_OFFICIAL", fmt.Sprintf("%t", official(metadata)))
75+
cmd.Env = append(os.Environ(),
76+
"ARDUINO_LINT_LIBRARY_MANAGER_INDEXING=true",
77+
fmt.Sprintf("ARDUINO_LINT_OFFICIAL=%t", official(metadata)))
7778

7879
textReport, lintErr := cmd.CombinedOutput()
7980
if lintErr != nil {

0 commit comments

Comments
 (0)