Snippet implements the Source interface method.
(line int)
| 153 | |
| 154 | // Snippet implements the Source interface method. |
| 155 | func (s *sourceImpl) Snippet(line int) (string, bool) { |
| 156 | charStart, found := s.findLineOffset(line) |
| 157 | if !found || s.Len() == 0 { |
| 158 | return "", false |
| 159 | } |
| 160 | charEnd, found := s.findLineOffset(line + 1) |
| 161 | if found { |
| 162 | return s.Slice(int(charStart), int(charEnd-1)), true |
| 163 | } |
| 164 | return s.Slice(int(charStart), s.Len()), true |
| 165 | } |
| 166 | |
| 167 | // findLineOffset returns the offset where the (1-indexed) line begins, |
| 168 | // or false if line doesn't exist. |
nothing calls this directly
no test coverage detected