(line int)
| 17 | } |
| 18 | |
| 19 | func (s Source) Snippet(line int) (string, bool) { |
| 20 | if s.raw == "" { |
| 21 | return "", false |
| 22 | } |
| 23 | var start int |
| 24 | for i := 1; i < line; i++ { |
| 25 | pos := strings.IndexByte(s.raw[start:], '\n') |
| 26 | if pos < 0 { |
| 27 | return "", false |
| 28 | } |
| 29 | start += pos + 1 |
| 30 | } |
| 31 | end := start + strings.IndexByte(s.raw[start:], '\n') |
| 32 | if end < start { |
| 33 | end = len(s.raw) |
| 34 | } |
| 35 | return s.raw[start:end], true |
| 36 | } |
no outgoing calls