mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
32 lines
429 B
Go
32 lines
429 B
Go
package reflectsource
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
func Example_getLineStartEndIndicies() {
|
|
b := []byte(`this
|
|
|
|
this is a longer line
|
|
and
|
|
stuff
|
|
last`)
|
|
|
|
for lineIndex := 0; ; lineIndex++ {
|
|
s, e := getLineStartEndIndicies(b, lineIndex)
|
|
fmt.Printf("%v: [%v, %v]\n", lineIndex, s, e)
|
|
if s == -1 {
|
|
break
|
|
}
|
|
}
|
|
|
|
// Output:
|
|
// 0: [0, 4]
|
|
// 1: [5, 5]
|
|
// 2: [6, 27]
|
|
// 3: [28, 31]
|
|
// 4: [32, 37]
|
|
// 5: [38, 42]
|
|
// 6: [-1, -1]
|
|
}
|