(input string, offset int)
| 795 | } |
| 796 | |
| 797 | func jsonLineAndChar(input string, offset int) (line int, character int, err error) { |
| 798 | lf := rune(0x0A) |
| 799 | |
| 800 | if offset > len(input) || offset < 0 { |
| 801 | return 0, 0, errors.Errorf("Couldn't find offset %d within the input.", offset) |
| 802 | } |
| 803 | |
| 804 | line = 1 |
| 805 | for i, b := range input { |
| 806 | if b == lf { |
| 807 | line++ |
| 808 | character = 0 |
| 809 | } |
| 810 | character++ |
| 811 | if i == offset { |
| 812 | break |
| 813 | } |
| 814 | } |
| 815 | |
| 816 | return line, character, nil |
| 817 | } |
no test coverage detected