(str string, ind int64)
| 647 | } |
| 648 | |
| 649 | func charAt(str string, ind int64) (string, error) { |
| 650 | i := int(ind) |
| 651 | runes := []rune(str) |
| 652 | if i < 0 || i > len(runes) { |
| 653 | return "", fmt.Errorf("index out of range: %d", ind) |
| 654 | } |
| 655 | if i == len(runes) { |
| 656 | return "", nil |
| 657 | } |
| 658 | return string(runes[i]), nil |
| 659 | } |
| 660 | |
| 661 | func indexOf(str, substr string) (int64, error) { |
| 662 | return indexOfOffset(str, substr, int64(0)) |