type Buffer … type edit … type edits … func (x edits) Len() int { … } func (x edits) Swap(i, j int) { … } func (x edits) Less(i, j int) bool { … } // NewBuffer returns a new buffer to accumulate changes to an initial data slice. // The returned buffer maintains a reference to the data, so the caller must ensure // the data is not modified until after the Buffer is done being used. func NewBuffer(old []byte) *Buffer { … } // Insert inserts the new string at old[pos:pos]. func (b *Buffer) Insert(pos int, new string) { … } // Delete deletes the text old[start:end]. func (b *Buffer) Delete(start, end int) { … } // Replace replaces old[start:end] with new. func (b *Buffer) Replace(start, end int, new string) { … } // Bytes returns a new byte slice containing the original data // with the queued edits applied. func (b *Buffer) Bytes() []byte { … } // String returns a string containing the original data // with the queued edits applied. func (b *Buffer) String() string { … }