config

package
v0.0.0-...-c0ec25b Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2014 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version = "0.0.1"
	Name    = "plethora"
)
View Source
const BucketName = "config"

Variables

This section is empty.

Functions

func Database

func Database(name string) (*bolt.DB, error)

Database returns the bolt database associated with the name given. If Database is called multiple times with the same name it will return the same *bolt.DB unless it was previously closed.

func DatabasePath

func DatabasePath(name string) string

DatabasePath returns the filepath to the database associated with the name given. This function can be used to use an alternate file-based database in code.

func Init

func Init() error

Init initializes the config package, this should be called before any other functions are used in this package.

func Location

func Location() string

Location returns the current location of the database

func TestConfiguration

func TestConfiguration() func()

TestConfiguration sets up temporary locations for configuration files, this should only be called in testing code.

The returned function should be called to cleanup any files that are created.

func UpdateLocation

func UpdateLocation(path string) error

UpdateLocation updates the database location in the dbloc file, this does not move any existing databases around.

Types

type Config

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

Config is a helper for configuration storage and retrieval.

func OpenConfig

func OpenConfig(name string) Config

OpenConfig returns the Config associated with the name given.

func (Config) Load

func (c Config) Load(key string, value interface{}) error

Load retrieves the value stored under the key and unmarshals it into the value given. If the key does not exist or is empty this returns err == nil.

Load uses an encoding to load the value, any fields in the value type need to be exported to load properly.

func (Config) Store

func (c Config) Store(key string, value interface{}) error

Store stores the value given under the key passed. Store encodes the value given before storing it. The encoding used can be found in the Config documentation.

Store uses an encoding to store the value given, this means that any fields in the value type need to be exported to be saved.

Jump to

Keyboard shortcuts

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