diff --git a/config/config.go b/config/config.go index 8461a89d2..a02f7fef5 100644 --- a/config/config.go +++ b/config/config.go @@ -14,8 +14,6 @@ import ( "strconv" "strings" "time" - - ustrings "github.com/coreos/etcd/pkg/strings" ) // The default location for the etcd configuration file. @@ -158,7 +156,7 @@ func (c *Config) loadEnv(target interface{}) error { case reflect.String: value.Field(i).SetString(v) case reflect.Slice: - value.Field(i).Set(reflect.ValueOf(ustrings.TrimSplit(v, ","))) + value.Field(i).Set(reflect.ValueOf(trimSplit(v, ","))) case reflect.Float64: newValue, err := strconv.ParseFloat(v, 64) if err != nil { @@ -239,10 +237,10 @@ func (c *Config) LoadFlags(arguments []string) error { // Convert some parameters to lists. if peers != "" { - c.Peers = ustrings.TrimSplit(peers, ",") + c.Peers = trimSplit(peers, ",") } if cors != "" { - c.CorsOrigins = ustrings.TrimSplit(cors, ",") + c.CorsOrigins = trimSplit(cors, ",") } return nil @@ -258,7 +256,7 @@ func (c *Config) LoadPeersFile() error { if err != nil { return fmt.Errorf("Peers file error: %s", err) } - c.Peers = ustrings.TrimSplit(string(b), ",") + c.Peers = trimSplit(string(b), ",") return nil } @@ -415,3 +413,14 @@ func sanitizeBindAddr(bindAddr string, aurl *url.URL) (string, error) { return net.JoinHostPort(bindAddr, aport), nil } + +// trimSplit slices s into all substrings separated by sep and returns a +// slice of the substrings between the separator with all leading and trailing +// white space removed, as defined by Unicode. +func trimSplit(s, sep string) []string { + trimmed := strings.Split(s, sep) + for i := range trimmed { + trimmed[i] = strings.TrimSpace(trimmed[i]) + } + return trimmed +} diff --git a/pkg/strings/string.go b/pkg/strings/string.go deleted file mode 100644 index 688b69d31..000000000 --- a/pkg/strings/string.go +++ /dev/null @@ -1,23 +0,0 @@ -package string - -import ( - "strings" -) - -// TrimSplit slices s into all substrings separated by sep and returns a -// slice of the substrings between the separator with all leading and trailing -// white space removed, as defined by Unicode. -func TrimSplit(s, sep string) []string { - trimmed := strings.Split(s, sep) - for i := range trimmed { - trimmed[i] = strings.TrimSpace(trimmed[i]) - } - return trimmed -} - -// Clone returns a copy of the string, so that we can safely point to the -// copy without worrying about changes via pointers. -func Clone(s string) string { - stringCopy := s - return stringCopy -} diff --git a/store/node.go b/store/node.go index 8ea253019..3e67fe858 100644 --- a/store/node.go +++ b/store/node.go @@ -6,7 +6,6 @@ import ( "time" etcdErr "github.com/coreos/etcd/error" - ustrings "github.com/coreos/etcd/pkg/strings" ) // explanations of Compare function result @@ -294,7 +293,7 @@ func (n *node) Repr(recurisive, sorted bool) *NodeExtern { } // since n.Value could be changed later, so we need to copy the value out - value := ustrings.Clone(n.Value) + value := n.Value node := &NodeExtern{ Key: n.Path, Value: &value, diff --git a/store/store.go b/store/store.go index c8a604748..b40dd4fac 100644 --- a/store/store.go +++ b/store/store.go @@ -26,7 +26,6 @@ import ( "time" etcdErr "github.com/coreos/etcd/error" - ustrings "github.com/coreos/etcd/pkg/strings" ) // The default version to set when the store is first initialized. @@ -236,7 +235,7 @@ func (s *store) CompareAndSwap(nodePath string, prevValue string, prevIndex uint n.UpdateTTL(expireTime) // copy the value for safety - valueCopy := ustrings.Clone(value) + valueCopy := value eNode.Value = &valueCopy eNode.Expiration, eNode.TTL = n.ExpirationAndTTL() @@ -432,7 +431,7 @@ func (s *store) Update(nodePath string, newValue string, expireTime time.Time) ( eNode.Dir = true } else { // copy the value for safety - newValueCopy := ustrings.Clone(newValue) + newValueCopy := newValue eNode.Value = &newValueCopy } @@ -504,7 +503,7 @@ func (s *store) internalCreate(nodePath string, dir bool, value string, unique, if !dir { // create file // copy the value for safety - valueCopy := ustrings.Clone(value) + valueCopy := value eNode.Value = &valueCopy n = newKV(s, nodePath, value, nextIndex, d, "", expireTime)