MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / jsonLineAndChar

Function jsonLineAndChar

dgraph/cmd/alpha/http.go:797–817  ·  view source on GitHub ↗
(input string, offset int)

Source from the content-addressed store, hash-verified

795}
796
797func jsonLineAndChar(input string, offset int) (line int, character int, err error) {
798 lf := rune(0x0A)
799
800 if offset > len(input) || offset < 0 {
801 return 0, 0, errors.Errorf("Couldn't find offset %d within the input.", offset)
802 }
803
804 line = 1
805 for i, b := range input {
806 if b == lf {
807 line++
808 character = 0
809 }
810 character++
811 if i == offset {
812 break
813 }
814 }
815
816 return line, character, nil
817}

Callers 1

convertJSONErrorFunction · 0.85

Calls 1

ErrorfMethod · 0.45

Tested by

no test coverage detected