envstore

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFn

func CreateFn[T any](key string, value T) func(*Store[T]) error

CreateFn returns a function that performs a Create operation

func DeleteFn

func DeleteFn[T any](key string) func(*Store[T]) error

DeleteFn returns a function that performs a Delete operation

func ReadFn

func ReadFn[T any](key string, fn func(T) error) func(*Store[T]) error

ReadFn returns a function that performs a Read operation

func UpdateFn

func UpdateFn[T any](key string, value T) func(*Store[T]) error

UpdateFn returns a function that performs an Update operation

Types

type Option

type Option[T any] func(*Store[T]) error

Option is a functional option pattern type for configuring Store

func WithEnvFile

func WithEnvFile[T any](filename string) Option[T]

WithEnvFile configures the store to load initial data from an env file

type Store

type Store[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any](opts ...Option[T]) (*Store[T], error)

New creates a new Store with optional configurations

func (*Store[T]) Create

func (s *Store[T]) Create(key string, value T) error

Create adds a new item to the store

func (*Store[T]) Delete

func (s *Store[T]) Delete(key string) error

Delete removes an item from the store

func (*Store[T]) GetEnv

func (s *Store[T]) GetEnv(key string) (string, error)

GetEnv reads a single value from the environment or env file

func (*Store[T]) Read

func (s *Store[T]) Read(key string) (T, error)

Read retrieves an item from the store

func (*Store[T]) Update

func (s *Store[T]) Update(key string, value T) error

Update modifies an existing item in the store

Jump to

Keyboard shortcuts

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