There is no strings.IndexFold() function like there is strings.EqualFold(), but we can use strings.EqualFold() to build our own case-insensitive substring search (as of Go 1.14).
(haystack, needle string)
| 594 | // but we can use strings.EqualFold() to build our own case-insensitive |
| 595 | // substring search (as of Go 1.14). |
| 596 | func indexFold(haystack, needle string) int { |
| 597 | nlen := len(needle) |
| 598 | for i := 0; i+nlen < len(haystack); i++ { |
| 599 | if strings.EqualFold(haystack[i:i+nlen], needle) { |
| 600 | return i |
| 601 | } |
| 602 | } |
| 603 | return -1 |
| 604 | } |
| 605 | |
| 606 | // isCELTryFilesLiteral returns whether the expression resolves to a map literal containing |
| 607 | // only string keys with or a placeholder call. |