json

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

package json provides Account storage in a simple, single JSON file. This module does no versioning or backups and is not suitable for non-trivial applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store holds the Account objects and can write them to disk.

func New

func New(path string, create bool) (*Store, error)

New creates a new Store object with the given file path. The create argument specifies whether or not a new store file should be created if it doesn't already exist.

func (*Store) Delete

func (s *Store) Delete(name string) error

Delete removes an Account from the store if it exists in the store.

func (*Store) Flush

func (s *Store) Flush() error

Flush writes all store data out to disk, overwriting existing data. Concurrent calls to Flush() are thread-safe but inefficient.

func (*Store) Get

func (s *Store) Get(name string) (*account.Account, error)

Get retrieves an Account object by name.

func (*Store) Rename

func (s *Store) Rename(newname string, a *account.Account) error

Rename moves an Account to be stored under a new name, replacing an Account if one already exists with the new name. The Account object is modified to receive the new name.

func (*Store) Update

func (s *Store) Update(a *account.Account) error

Update updates the internal representation of an Account.

Jump to

Keyboard shortcuts

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