jsonio

package
v0.0.0-...-63ef27d Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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.

Types

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.

Jump to

Keyboard shortcuts

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