conf

package
v0.0.0-...-c6e3130 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 2 Imported by: 5

Documentation

Overview

Package conf is a configuration package. It can be used to store configuration data in multiple different pluggable backends

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is the error returned when a config item isn't found

Functions

func GetInt

func GetInt(name string) (int, error)

GetInt calls Default.GetInt

func SetInt

func SetInt(name string, i int)

SetInt calls Default.SetInt

Types

type Data

type Data interface {
	// SetInt sets the config value at name to i, overwriting if it already exists
	SetInt(name string, i int)
	// GetInt gets the config value at name. Returns 0, ErrNotFound if not such value found
	GetInt(name string) (int, error)
}

Data is the core config interface

var Default Data = NewMem()

Default is an in-memory config backend. It's used in the SetInt and GetInt calls, and it's the optional singleton. Some packages export this name and others don't. If it's exported, it's the library user's responsibility to set it correctly and avoid concurrency issues (like setting it from two different goroutines, which would be a race condition)

func NewMem

func NewMem() Data

NewMem creates a Data implementation that stores config data in memory

Jump to

Keyboard shortcuts

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