MCPcopy Index your code
hub / github.com/maruel/panicparse / lineToByteOffsets

Function lineToByteOffsets

stack/source.go:95–106  ·  view source on GitHub ↗

lineToByteOffsets extract the line number into raw file offset. Inserts a dummy 0 at offset 0 so line offsets can be 1 based.

(src []byte)

Source from the content-addressed store, hash-verified

93//
94// Inserts a dummy 0 at offset 0 so line offsets can be 1 based.
95func lineToByteOffsets(src []byte) []int {
96 offsets := []int{0, 0}
97 for offset := 0; offset < len(src); {
98 n := bytes.IndexByte(src[offset:], '\n')
99 if n == -1 {
100 break
101 }
102 offset += n + 1
103 offsets = append(offsets, offset)
104 }
105 return offsets
106}
107
108// parsedFile is a processed Go source file.
109type parsedFile struct {

Callers 2

loadFileMethod · 0.85
TestLineToByteOffsetsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestLineToByteOffsetsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…