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

file

package
v0.2.17 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Options) error

Option is a function that takes in an options struct and sets values or returns an error

func WithBaseDirectory

func WithBaseDirectory(with string) Option

WithDirectory allows specifying a base directory to use

func WithSkipCleanup

func WithSkipCleanup(with bool) Option

WithSkipCleanup causes FileStorage cleanup to be a no-op, useful for inspecting state after the fact

type Options

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

type Storage

type Storage struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, opt ...Option) (*Storage, error)

New creates a new object that implements the Storage interface in an on-disk directory. This is not currently explicitly thread-safe, although it may work without issue in that manner. Call Cleanup() when done with it.

Supported options: WithBaseDirectory, WithSkipCleanup

For safety, if a base directory is specified (that is, it's not a temporary directory generated by this function), cleanup is _always_ skipped.

func (*Storage) BaseDir

func (ts *Storage) BaseDir() string

Returns the base directory being used, useful for displaying in tests for after-test inspection

func (*Storage) Cleanup

func (ts *Storage) Cleanup(_ context.Context) error

Cleanup provides a function to clean up after tests

func (*Storage) List

func (ts *Storage) List(ctx context.Context, msg proto.Message) ([]string, error)

List implements the Storage interface

func (*Storage) Load

Load implements the Storage interface

func (*Storage) Remove

Remove implements the Storage interface

func (*Storage) Store

Store implements the Storage interface.

If the message already exists, it is overwritten.

Jump to

Keyboard shortcuts

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