NewStringSource creates a new Source from the given contents and description.
(contents string, description string)
| 82 | |
| 83 | // NewStringSource creates a new Source from the given contents and description. |
| 84 | func NewStringSource(contents string, description string) Source { |
| 85 | // Compute line offsets up front as they are referred to frequently. |
| 86 | buf, offs := runes.NewBufferAndLineOffsets(contents) |
| 87 | return &sourceImpl{ |
| 88 | Buffer: buf, |
| 89 | description: description, |
| 90 | lineOffsets: offs, |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | // NewStringSourceWithLimit creates a new Source from the given contents and |
| 95 | // description while enforcing a maximum code point count when needed. |