Back to

Package jsonio

Latest Go to latest

The latest major version is .

Published: Aug 22, 2020 | License: MIT | Module:


Package jsonio contains I/O functions for persisting data with json.


func ReadMessage

func ReadMessage(fname string, v interface{}) error

ReadMessage reads a json-encoded value from fname, and unmarshalls it into v.

func WriteMessage

func WriteMessage(fname string, v interface{}, perm os.FileMode) error

WriteMessage marshals v to json, and atomically writes it into fname.

type Store

type Store struct {
	// contains filtered or unexported fields

Store represents a persistent json message store.

func NewStore

func NewStore(dir string) (*Store, error)

NewStore returns a new Store instance. It will create dir if needed.

func (*Store) Get

func (s *Store) Get(id string, v interface{}) (bool, error)

Get a message from the store.

func (*Store) ListIDs

func (s *Store) ListIDs() ([]string, error)

ListIDs in the store.

func (*Store) Put

func (s *Store) Put(id string, v interface{}) error

Put a message into the store.

func (*Store) Remove

func (s *Store) Remove(id string) (bool, error)

Remove a message from the store.

Package Files

  • jsonio.go
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier