MCPcopy Create free account
hub / github.com/sergi/go-diff / indexOf

Function indexOf

diffmatchpatch/stringutil.go:32–44  ·  view source on GitHub ↗

indexOf returns the first index of pattern in str, starting at str[i].

(str string, pattern string, i int)

Source from the content-addressed store, hash-verified

30
31// indexOf returns the first index of pattern in str, starting at str[i].
32func indexOf(str string, pattern string, i int) int {
33 if i > len(str)-1 {
34 return -1
35 }
36 if i <= 0 {
37 return strings.Index(str, pattern)
38 }
39 ind := strings.Index(str[i:], pattern)
40 if ind == -1 {
41 return -1
42 }
43 return ind + i
44}
45
46// lastIndexOf returns the last index of pattern in str, starting at str[i].
47func lastIndexOf(str string, pattern string, i int) int {

Callers 3

TestIndexOfFunction · 0.85
MatchBitapMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestIndexOfFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…