Skip to content

Commit 703f138

Browse files
stuart-warrenmattn
authored andcommitted
use strings.HasPrefix
1 parent 024f1b8 commit 703f138

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

etcdenv.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ var host = flag.String("host", "", "etcd host")
1818
var hosts []string
1919
var envs []string
2020

21-
func stringInSlice(s string, list []string) int {
21+
func prefixInSlice(list []string, s string) int {
2222
for i, entry := range list {
23-
if strings.Contains(entry, s) {
23+
if strings.HasPrefix(entry, s) {
2424
return i
2525
}
2626
}
@@ -31,8 +31,8 @@ func handleNode(n *etcd.Node) {
3131
if !n.Dir {
3232
key := strings.Split(n.Key, "/")
3333
k, v := strings.ToUpper(key[len(key)-1]), n.Value
34-
// if key already exists and in recursive mode, append with comma
35-
if i := stringInSlice(k+"=", envs); i != -1 && *rec {
34+
// if k already exists and in recursive mode, append v with comma
35+
if i := prefixInSlice(envs, k+"="); i != -1 && *rec {
3636
envs[i] = fmt.Sprint(envs[i], ",", v)
3737
} else {
3838
envs = append(envs, k+"="+v)

0 commit comments

Comments
 (0)