MCPcopy Create free account
hub / github.com/dgraph-io/dgraph-benchmarks / findFeatureArray

Function findFeatureArray

geofreebase/main.go:38–69  ·  view source on GitHub ↗
(dec *json.Decoder)

Source from the content-addressed store, hash-verified

36}
37
38func findFeatureArray(dec *json.Decoder) error {
39 for {
40 t, err := dec.Token()
41 if err == io.EOF {
42 break
43 }
44 if err != nil {
45 return err
46 }
47 if s, ok := t.(string); ok && s == "features" && dec.More() {
48 // we found the features element
49 d, err := dec.Token()
50 if err != nil {
51 return err
52 }
53 if delim, ok := d.(json.Delim); ok {
54 if delim.String() == "[" {
55 // we have our start of the array
56 break
57 } else {
58 // A different kind of delimiter
59 return fmt.Errorf("Expected features to be an array.")
60 }
61 }
62 }
63 }
64
65 if !dec.More() {
66 return fmt.Errorf("Cannot find any features.")
67 }
68 return nil
69}
70
71func main() {
72 flag.Parse()

Callers 1

mainFunction · 0.70

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected