Help us shape the future of Go! Take the 2026 Go Developer Survey

history

package
v1.49.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type History

type History struct {
	Messages []string `json:"messages"`
	// contains filtered or unexported fields
}

func New

func New(opts ...Opt) (*History, error)

func (*History) Add

func (h *History) Add(message string) error

func (*History) FindNextContains

func (h *History) FindNextContains(query string, from int) (msg string, idx int, ok bool)

FindNextContains searches forward through history for a message containing query. from is an exclusive lower bound index. Pass -1 to start from the oldest. Returns the matched message, its index, and whether a match was found.

func (*History) FindPrevContains

func (h *History) FindPrevContains(query string, from int) (msg string, idx int, ok bool)

FindPrevContains searches backward through history for a message containing query. from is an exclusive upper bound index. Pass len(Messages) to start from the most recent. Returns the matched message, its index, and whether a match was found. An empty query matches any entry.

func (*History) LatestMatch

func (h *History) LatestMatch(prefix string) string

LatestMatch returns the most recent history entry that extends the provided prefix, or the latest message when no prefix is supplied.

func (*History) Next

func (h *History) Next() string

func (*History) Previous

func (h *History) Previous() string

func (*History) SetCurrent

func (h *History) SetCurrent(i int)

type Opt

type Opt func(*options)

func WithBaseDir

func WithBaseDir(dir string) Opt

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL