recent

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package recent remembers the directories that have been attached, most recent first.

It is a convenience and nothing more, so every failure in it is swallowed: a read-only home directory should cost the list, not the session. That is the same bargain the catalog cache and the query history strike.

A JSON file rather than a table. The catalog database is the schema cache and the history database is the query log; a list of twenty paths belongs in neither, and giving it a third database would be more machinery than the thing it stores.

Index

Constants

View Source
const Limit = 20

Limit is how many paths are kept. Long enough to cover the checkouts someone moves between, short enough that the list is still a shortcut.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns the on-disk location, alongside the catalog cache and the query history.

Types

type List

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

List is an ordered set of paths, most recent first.

The zero value is an empty list that remembers nothing across runs, which is what a session gets when the state directory could not be read.

func Open

func Open(path string) (*List, error)

Open reads a list.

A missing file is the ordinary first run, and an unreadable or malformed one is treated the same way: starting over loses a list of paths, whereas refusing to start loses the feature for good, and nobody is going to hand- repair a state file to get their directory history back.

func (*List) Add

func (l *List) Add(path string)

Add records a path, moving it to the front if it is already known.

func (*List) Entries

func (l *List) Entries() []string

Entries returns the paths, most recent first.

func (*List) Save

func (l *List) Save() error

Save writes the list, creating the directory if it is not there.

A list with nowhere to write is not an error: it is the in-memory fallback a session gets when the state directory was unusable, and it should keep working for the rest of the session.

Jump to

Keyboard shortcuts

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