forked from arduino/arduino-create-agent
/
utils.go
44 lines (36 loc) · 811 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package upload
// Logger is an interface implemented by most loggers (like logrus)
type Logger interface {
Debug(args ...interface{})
Info(args ...interface{})
}
func debug(l Logger, args ...interface{}) {
if l != nil {
l.Debug(args...)
}
}
func info(l Logger, args ...interface{}) {
if l != nil {
l.Info(args...)
}
}
// Locater can return the location of a tool in the system
type Locater interface {
GetLocation(command string) (string, error)
}
// differ returns the first item that differ between the two input slices
func differ(slice1 []string, slice2 []string) string {
m := map[string]int{}
for _, s1Val := range slice1 {
m[s1Val] = 1
}
for _, s2Val := range slice2 {
m[s2Val] = m[s2Val] + 1
}
for mKey, mVal := range m {
if mVal == 1 {
return mKey
}
}
return ""
}