etcd/pkg/strings/string.go
evan-gu 9cfd8c5f0b fix(store): make NodeExtern.Value a *string
Before this change if the value of a Node was "" it would get dropped from the json
encoding and the Node.Value field would be missing. Fix this problem by making
NodeExtern.Value a *string so that an empty string will be encoded but a nil value
will drop the field.
2014-02-18 00:50:44 -05:00

24 lines
601 B
Go

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
}