go: github.com/golang/go/src/cmd/internal/edit Index | Files

package edit

import "github.com/golang/go/src/cmd/internal/edit"

Package edit implements buffered position-based editing of byte slices.

Index

Package Files

edit.go

type Buffer Uses

type Buffer struct {
    // contains filtered or unexported fields
}

A Buffer is a queue of edits to apply to a given byte slice.

func NewBuffer Uses

func NewBuffer(data []byte) *Buffer

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 (*Buffer) Bytes Uses

func (b *Buffer) Bytes() []byte

Bytes returns a new byte slice containing the original data with the queued edits applied.

func (*Buffer) Delete Uses

func (b *Buffer) Delete(start, end int)

func (*Buffer) Insert Uses

func (b *Buffer) Insert(pos int, new string)

func (*Buffer) Replace Uses

func (b *Buffer) Replace(start, end int, new string)

func (*Buffer) String Uses

func (b *Buffer) String() string

String returns a string containing the original data with the queued edits applied.

Package edit imports 2 packages (graph). Updated 2019-01-21. Refresh now. Tools for package owners.