github.com/alpe/etcd@v0.1.2-0.20130915230056-09f31af88aeb/store/keywords.go (about) 1 package store 2 3 import ( 4 "path" 5 "strings" 6 ) 7 8 // keywords for internal useage 9 // Key for string keyword; Value for only checking prefix 10 var keywords = map[string]bool{ 11 "/_etcd": true, 12 "/ephemeralNodes": true, 13 } 14 15 // CheckKeyword will check if the key contains the keyword. 16 // For now, we only check for prefix. 17 func CheckKeyword(key string) bool { 18 key = path.Clean("/" + key) 19 20 // find the second "/" 21 i := strings.Index(key[1:], "/") 22 23 var prefix string 24 25 if i == -1 { 26 prefix = key 27 } else { 28 prefix = key[:i+1] 29 } 30 _, ok := keywords[prefix] 31 32 return ok 33 }