type Buffer … type emptyBuffer … func (e *emptyBuffer) Get(i int) rune { … } func (e *emptyBuffer) Slice(i, j int) string { … } func (e *emptyBuffer) Len() int { … } var _ … type asciiBuffer … func (a *asciiBuffer) Get(i int) rune { … } func (a *asciiBuffer) Slice(i, j int) string { … } func (a *asciiBuffer) Len() int { … } var _ … type basicBuffer … func (b *basicBuffer) Get(i int) rune { … } func (b *basicBuffer) Slice(i, j int) string { … } func (b *basicBuffer) Len() int { … } var _ … type supplementalBuffer … func (s *supplementalBuffer) Get(i int) rune { … } func (s *supplementalBuffer) Slice(i, j int) string { … } func (s *supplementalBuffer) Len() int { … } var _ … var nilBuffer … // NewBuffer returns an efficient implementation of Buffer for the given text based on the ranges of // the encoded code points contained within. // // Code points are represented as an array of byte, uint16, or rune. This approach ensures that // each index represents a code point by itself without needing to use an array of rune. At first // we assume all code points are less than or equal to '\u007f'. If this holds true, the // underlying storage is a byte array containing only ASCII characters. If we encountered a code // point above this range but less than or equal to '\uffff' we allocate a uint16 array, copy the // elements of previous byte array to the uint16 array, and continue. If this holds true, the // underlying storage is a uint16 array containing only Unicode characters in the Basic Multilingual // Plane. If we encounter a code point above '\uffff' we allocate an rune array, copy the previous // elements of the byte or uint16 array, and continue. The underlying storage is an rune array // containing any Unicode character. func NewBuffer(data string) Buffer { … } // NewBufferAndLineOffsets returns an efficient implementation of Buffer for the given text based on // the ranges of the encoded code points contained within, as well as returning the line offsets. // // Code points are represented as an array of byte, uint16, or rune. This approach ensures that // each index represents a code point by itself without needing to use an array of rune. At first // we assume all code points are less than or equal to '\u007f'. If this holds true, the // underlying storage is a byte array containing only ASCII characters. If we encountered a code // point above this range but less than or equal to '\uffff' we allocate a uint16 array, copy the // elements of previous byte array to the uint16 array, and continue. If this holds true, the // underlying storage is a uint16 array containing only Unicode characters in the Basic Multilingual // Plane. If we encounter a code point above '\uffff' we allocate an rune array, copy the previous // elements of the byte or uint16 array, and continue. The underlying storage is an rune array // containing any Unicode character. func NewBufferAndLineOffsets(data string) (Buffer, []int32) { … } func newBuffer(data string, lines bool) (Buffer, []int32) { … }