storage

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 9 Imported by: 0

README

go-storage

A simple storage abstraction library.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConflict = NewStorageErrorKind("conflict state")
View Source
var ErrInvalid = NewStorageErrorKind("invalid argument")
View Source
var ErrInvalidKey = NewStorageErrorKind("invalid key")
View Source
var ErrKeyNotExist = NewStorageErrorKind("key does not exist")
View Source
var ErrNotFound = NewStorageErrorKind("not found")
View Source
var ErrPermission = NewStorageErrorKind("permission denied")
View Source
var ErrStorage = NewStorageErrorKind("storage error") // HTTP 500
View Source
var ErrUnknown = NewStorageErrorKind("unknown error")

Functions

func NormalizeKey

func NormalizeKey(key string) (string, error)

func NormalizeMetadataKey

func NormalizeMetadataKey(key string) string

Normalize Metadate key to Canonical Header uwu;

Types

type GetOptions

type GetOptions struct {
	Range *Range
}

func GetOptionsOrDefault

func GetOptionsOrDefault(opts *GetOptions) *GetOptions

type Metadata

type Metadata map[string]string

Key: /[a-z0-9\-_]+/

func NormalizeMetadata

func NormalizeMetadata(metadata Metadata) Metadata

type PutOptions

type PutOptions struct {
	ContentType string
	Metadata    Metadata
}

func PutOptionsOrDefault

func PutOptionsOrDefault(opts *PutOptions) *PutOptions

type Range

type Range struct {
	Start int64
	End   int64
}

zero-indexed & inclusive; https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Range

type Stats

type Stats struct {
	ETag         string
	ContentType  string
	Size         int64
	LastModified time.Time

	Metadata Metadata
}

type Storage

type Storage interface {
	Put(ctx context.Context, key string, reader io.Reader, size int64, opts *PutOptions) error

	Get(ctx context.Context, key string, opts *GetOptions) (io.ReadCloser, *Stats, error)

	Delete(ctx context.Context, key string) error

	Stat(ctx context.Context, key string) (*Stats, error)
}

type StorageError

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

func AsStorageError

func AsStorageError(err error) (StorageError, bool)

func (StorageError) Error

func (e StorageError) Error() string

func (StorageError) Unwrap

func (e StorageError) Unwrap() error

type StorageErrorKind

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

func NewStorageErrorKind

func NewStorageErrorKind(name string) *StorageErrorKind

func (*StorageErrorKind) Error

func (k *StorageErrorKind) Error() string

func (*StorageErrorKind) New

func (k *StorageErrorKind) New(msg string) StorageError

func (*StorageErrorKind) Newf

func (k *StorageErrorKind) Newf(msg string, a ...any) StorageError

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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