data

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Unlicense Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Dir = ".godo"
View Source
const JSONFile = "godo.json"

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func Compare

func Compare(a, b types.Actionable) int

func DotGodoDirCreater

func DotGodoDirCreater(parent string) func() error

func FileCreater

func FileCreater(path string) func() error

func JSONDecode

func JSONDecode(r io.Reader) (map[types.ID]types.Actionable, error)

func JSONEncode

func JSONEncode(abstractMap map[types.ID]types.Actionable, w io.Writer) error

Types

type Comparer

type Comparer func(a, b types.Actionable) int

type Decoder

type Decoder func(io.Reader) (map[types.ID]types.Actionable, error)

type Encoder

type Encoder func(map[types.ID]types.Actionable, io.Writer) error

type Getter

type Getter interface {
	Get(types.ID) (types.Actionable, error)
}

type JSON

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

func (*JSON) Get

func (j *JSON) Get(id types.ID) (types.Actionable, error)

func (*JSON) List

func (j *JSON) List() ([]types.Actionable, error)

func (*JSON) Put

func (j *JSON) Put(a types.Actionable) error

func (*JSON) Remove

func (j *JSON) Remove(id types.ID) error

type Lister

type Lister interface {
	List() ([]types.Actionable, error)
}

type Logger

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

func (Logger) Get

func (l Logger) Get(id types.ID) (types.Actionable, error)

Get implements Repository.

func (Logger) List

func (l Logger) List() ([]types.Actionable, error)

List implements Repository.

func (Logger) Put

func (l Logger) Put(a types.Actionable) error

Put implements Repository.

func (Logger) Remove

func (l Logger) Remove(id types.ID) error

Remove implements Repository.

type Mock

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

Mock is a data persistency strategy that has predefined values

func (Mock) Get

func (m Mock) Get(id types.ID) (types.Actionable, error)

Get implements Repository.

func (Mock) Initialize

func (m Mock) Initialize() error

Initialize implements Repository.

func (Mock) List

func (m Mock) List() ([]types.Actionable, error)

List implements Repository.

func (Mock) Put

func (m Mock) Put(types.Actionable) error

Put implements Repository.

func (Mock) Remove

func (m Mock) Remove(types.ID) error

Remove implements Repository.

type Putter

type Putter interface {
	Put(types.Actionable) error
}

type ReadGetter

type ReadGetter func() (io.ReadCloser, error)

func FileReader

func FileReader(path string) ReadGetter

type Remover

type Remover interface {
	Remove(types.ID) error
}

type Repository

type Repository interface {
	Getter
	Lister
	Putter
	Remover
}

func LoggerOverRepository

func LoggerOverRepository(repo Repository) Repository

func MockWithData

func MockWithData(data map[types.ID]types.Actionable) Repository

func NewJSONRepository

func NewJSONRepository(
	rdr ReadGetter,
	wrt WriterGetter,
	dec Decoder,
	enc Encoder,
	cmp Comparer,
) Repository

type WriterGetter

type WriterGetter func() (io.WriteCloser, error)

func FileWriter

func FileWriter(path string) WriterGetter

Jump to

Keyboard shortcuts

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