confy

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: MIT Imports: 6 Imported by: 3

README

confy

A stupid simple configuration store.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormKey added in v0.7.0

func NormKey(key string) string

NormKey returns the normalised form of a given key.

Confy implementations should use this to achieve consistent behaviour.

Types

type Confy

type Confy interface {
	Get(key string, ptr interface{}) error
	Set(key string, val interface{}) error
	Del(key string) error
	Keys() ([]string, error)
}

A Confy is a stupid simple configuration store.

type OS added in v0.7.0

type OS struct {
	Directory string
	Extension string
}

OS is a Confy which uses functionality from package os.

func NewOS added in v0.7.0

func NewOS(dir, ext string) (*OS, error)

NewOS creates a new OS with the given directory and extension.

func (*OS) Del added in v0.7.0

func (o *OS) Del(key string) error

Del removes the file corresponding to the given key.

func (*OS) Get added in v0.7.0

func (o *OS) Get(key string, ptr interface{}) error

Get loads JSON data into ptr from the file corresponding to the given key.

func (*OS) Keys added in v0.7.0

func (o *OS) Keys() ([]string, error)

Keys fetches a list of existing keys using os.ReadDir, filtered by o.Extension and NormKey.

func (*OS) Set added in v0.7.0

func (o *OS) Set(key string, val interface{}) error

Set writes val in JSON format to the file corresponding to the given key.

Jump to

Keyboard shortcuts

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