github.com/elves/elvish@v0.15.0/pkg/strutil/eol_sol.go (about) 1 package strutil 2 3 import ( 4 "strings" 5 ) 6 7 // FindFirstEOL returns the index of the first '\n'. When there is no '\n', the 8 // length of s is returned. 9 func FindFirstEOL(s string) int { 10 eol := strings.IndexRune(s, '\n') 11 if eol == -1 { 12 eol = len(s) 13 } 14 return eol 15 } 16 17 // FindLastSOL returns an index just after the last '\n'. 18 func FindLastSOL(s string) int { 19 return strings.LastIndex(s, "\n") + 1 20 }