Я имею в виду, что вы могли бы написать супер простой парсер:
https://play.golang.org/p/q0oeNlhSKJT
func parse(s string) {
tokens := make(map[string]string)
key := []byte{}
value := []byte{}
inQuote := false
inKey := true
for i := 0; i < len(s); i++ {
ch := s[i]
// If we see a :, we're switching from key to value (or vice versa)
// unless we're inside of a quote
if ch == ':' && !inQuote {
inKey = !inKey
// if we see a ", we're switching from in a quote to out or out to in
} else if ch == '"' {
inQuote = !inQuote
// if we see a space, and we're not in a quote, we've completed a key value pair
} else if ch == ' ' && !inQuote {
inKey = !inKey
if inKey {
tokens[string(key)] = string(value)
key = []byte{}
value = []byte{}
}
// otherwise, add this character to either they key or the value
} else if inKey {
key = append(key, ch)
} else {
value = append(value, ch)
}
}
// add the final key value pair
tokens[string(key)] = string(value)
// print out the ones with keys >= 3000
for k, v := range tokens {
n, _ := strconv.Atoi(k)
if (n >= 3000) {
fmt.Println("K: " + k + " | V: " + v)
}
}
}