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

storage

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileStrategy

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

FileStrategy is a Storage that reads/persists data to/from a file at the provided path

func (*FileStrategy) Read

func (fs *FileStrategy) Read() ([]byte, error)

Read reads data from the file at the provided path

func (*FileStrategy) Write

func (fs *FileStrategy) Write(data []byte) error

Write writes data to the file at the provided path

type Storage

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

Storage represents something that can write user data to some form of Storage

func New

func New(strategy Strategy) *Storage

New returns a new Storage given a Strategy

func (*Storage) Clear

func (s *Storage) Clear() error

Clear clears out a user's data from Storage

func (*Storage) ReadUserConfig

func (s *Storage) ReadUserConfig() (*user.User, error)

ReadUserConfig reads the user data from Storage

func (*Storage) WriteUserConfig

func (s *Storage) WriteUserConfig(u *user.User) error

WriteUserConfig writes the user data to Storage

type Strategy

type Strategy interface {
	Read() ([]byte, error)
	Write(data []byte) error
}

Strategy represents a means of reading and writing data

func NewFileStrategy

func NewFileStrategy(path string) (Strategy, error)

NewFileStrategy returns a new FileStrategy given a location on disk to store data

Jump to

Keyboard shortcuts

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