MCPcopy
hub / github.com/protocolbuffers/protobuf-go / Position

Method Position

internal/encoding/json/decode.go:225–233  ·  view source on GitHub ↗

Position returns line and column number of given index of the original input. It will panic if index is out of range.

(idx int)

Source from the content-addressed store, hash-verified

223// Position returns line and column number of given index of the original input.
224// It will panic if index is out of range.
225func (d *Decoder) Position(idx int) (line int, column int) {
226 b := d.orig[:idx]
227 line = bytes.Count(b, []byte("\n")) + 1
228 if i := bytes.LastIndexByte(b, '\n'); i >= 0 {
229 b = b[i+1:]
230 }
231 column = utf8.RuneCount(b) + 1 // ignore multi-rune characters
232 return line, column
233}
234
235// currPos returns the current index position of d.in from d.orig.
236func (d *Decoder) currPos() int {

Callers 6

newSyntaxErrorMethod · 0.95
newErrorMethod · 0.45
syntaxErrorMethod · 0.45
newErrorMethod · 0.45
syntaxErrorMethod · 0.45
generatedCodeInfoMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected