type of key returns the identifier in k before the first ":" or "|". (Originally we packed keys by hand and there are a mix of styles)
(k string)
| 33 | // type of key returns the identifier in k before the first ":" or "|". |
| 34 | // (Originally we packed keys by hand and there are a mix of styles) |
| 35 | func typeOfKey(k string) string { |
| 36 | c := strings.Index(k, ":") |
| 37 | p := strings.Index(k, "|") |
| 38 | if c < 0 && p < 0 { |
| 39 | return "" |
| 40 | } |
| 41 | if c < 0 { |
| 42 | return k[:p] |
| 43 | } |
| 44 | if p < 0 { |
| 45 | return k[:c] |
| 46 | } |
| 47 | min := c |
| 48 | if p < min { |
| 49 | min = p |
| 50 | } |
| 51 | return k[:min] |
| 52 | } |
| 53 | |
| 54 | type keyType struct { |
| 55 | name string |