gofilestorer

package module
v0.0.0-...-5f259e1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

README

Go

Go Filestorer

A generic implementation for file storer patterns meant for rapid prototyping. This storer supports multiple file types using the same interfaces across implementations for ease of use. Reader and Writer interfaces are provided for flexibility.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorDataNotExists = errors.New("data not exists")
)

Functions

This section is empty.

Types

type Data

type Data struct {
	ID        uint64    `json:"id" csv:"id"`
	CreatedAt time.Time `json:"created_at" csv:"created_at"`
}

type Reader

type Reader[D any] interface {
	Read() ([]D, error)
	// contains filtered or unexported methods
}

func NewCSVReader

func NewCSVReader[D reader](fs afero.Fs, fileName string, separator rune) (Reader[D], error)

Create a new reader that is backed by a CSV file

func NewJSONReader

func NewJSONReader[D reader](fs afero.Fs, fileName string) (Reader[D], error)

Create a new reader that is backed by a JSON file

type Writer

type Writer[D any] interface {
	Create(D) error
	Read() ([]D, error)
	Update(D) error
	Delete(uint64) error
	Upsert(D) error
	// contains filtered or unexported methods
}

func NewCSVWriter

func NewCSVWriter[D writer](fs afero.Fs, fileName string, separator rune) (Writer[D], error)

Create a new writer that is backed by a CSV file

func NewJSONWriter

func NewJSONWriter[D writer](fs afero.Fs, fileName string) (Writer[D], error)

Create a new writer that is backed by a JSON file

Jump to

Keyboard shortcuts

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