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

Function findFeatureArray

geotordf/main.go:25–56  ·  view source on GitHub ↗
(dec *json.Decoder)

Source from the content-addressed store, hash-verified

23)
24
25func findFeatureArray(dec *json.Decoder) error {
26 for {
27 t, err := dec.Token()
28 if err == io.EOF {
29 break
30 }
31 if err != nil {
32 return err
33 }
34 if s, ok := t.(string); ok && s == "features" && dec.More() {
35 // we found the features element
36 d, err := dec.Token()
37 if err != nil {
38 return err
39 }
40 if delim, ok := d.(json.Delim); ok {
41 if delim.String() == "[" {
42 // we have our start of the array
43 break
44 } else {
45 // A different kind of delimiter
46 return fmt.Errorf("Expected features to be an array.")
47 }
48 }
49 }
50 }
51
52 if !dec.More() {
53 return fmt.Errorf("Cannot find any features.")
54 }
55 return nil
56}
57
58func main() {
59 flag.Parse()

Callers 1

mainFunction · 0.70

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected