config

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2021 License: MIT Imports: 7 Imported by: 1

README

go-config

A very light wrapper around pelletier's go-toml library for parsing and tracking values from a configuration file.

Mostly mimics the official Go flag library in usage.

Possible types for tracking include:

  • bool
  • int64
  • uint64
  • float64
  • string
  • time.Time
  • time.Duration
  • []interface{} (any of the above)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(key string, defaultValue bool) *bool

Bool defines a TOML key to bool value to track

func BoolArray

func BoolArray(key string, defaultValue []bool) *[]bool

BoolArray defines a TOML key to bool array value to track

func BoolArrayVar

func BoolArrayVar(ptr *[]bool, key string, defaultValue []bool)

BoolArrayVar defines a TOML key to bool array value to track, storing value in provided pointer

func BoolVar

func BoolVar(ptr *bool, key string, defaultValue bool)

BoolVar defines a TOML key to bool value to track, storing value in provided pointer

func Duration

func Duration(key string, defaultValue time.Duration) *time.Duration

Duration defines a TOML key to time.Duration value to track

func DurationArray

func DurationArray(key string, defaultValue []time.Duration) *[]time.Duration

DurationArray defines a TOML key to time.Duration array value to track

func DurationArrayVar

func DurationArrayVar(ptr *[]time.Duration, key string, defaultValue []time.Duration)

DurationArrayVar defines a TOML key to time.Duration array value to track, storing value in provided pointer

func DurationVar

func DurationVar(ptr *time.Duration, key string, defaultValue time.Duration)

DurationVar defines a TOML key to time.Duration value to track, storing value in provided pointer

func Float64

func Float64(key string, defaultValue float64) *float64

Float64 defines a TOML key to float64 value to track

func Float64Array

func Float64Array(key string, defaultValue []float64) *[]float64

Float64Array defines a TOML key to float64 array value to track

func Float64ArrayVar

func Float64ArrayVar(ptr *[]float64, key string, defaultValue []float64)

Float64ArrayVar defines a TOML key to float64 array value to track, storing value in provided pointer

func Float64Var

func Float64Var(ptr *float64, key string, defaultValue float64)

Float64Var defines a TOML key to float64 value to track, storing value in provided pointer

func Int64

func Int64(key string, defaultValue int64) *int64

Int64 defines a TOML key to int64 value to track

func Int64Array

func Int64Array(key string, defaultValue []int64) *[]int64

Int64Array defines a TOML key to int64 array value to track

func Int64ArrayVar

func Int64ArrayVar(ptr *[]int64, key string, defaultValue []int64)

Int64ArrayVar defines a TOML key to int64 array value to track, storing value in provided pointer

func Int64Var

func Int64Var(ptr *int64, key string, defaultValue int64)

Int64Var defines a TOML key to int64 value to track, storing value in provided pointer

func Parse

func Parse(path string)

Parse attempts to parse the configuration file at path

func ParseDefined

func ParseDefined(path string) (map[string]interface{}, error)

ParseDefined attempts to parse the configuration file at Path, returning a map of any undefined keys

func String

func String(key string, defaultValue string) *string

String defines a TOML key to string value to track

func StringArray

func StringArray(key string, defaultValue []string) *[]string

StringArray defines a TOML key to string array value to track

func StringArrayVar

func StringArrayVar(ptr *[]string, key string, defaultValue []string)

StringArrayVar defines a TOML key to string array value to track, storing value in provided pointer

func StringVar

func StringVar(ptr *string, key string, defaultValue string)

StringVar defines a TOML key to string value to track, storing value in provided pointer

func Time

func Time(key string, defaultValue time.Time) *time.Time

Time defines a TOML key to time.Time value to track

func TimeArray

func TimeArray(key string, defaultValue []time.Time) *[]time.Time

TimeArray defines a TOML key to time.Time array value to track

func TimeArrayVar

func TimeArrayVar(ptr *[]time.Time, key string, defaultValue []time.Time)

TimeArrayVar defines a TOML key to time.Time array value to track, storing value in provided pointer

func TimeVar

func TimeVar(ptr *time.Time, key string, defaultValue time.Time)

TimeVar defines a TOML key to time.Time value to track, storing value in provided pointer

func Uint64

func Uint64(key string, defaultValue uint64) *uint64

Uint64 defines a TOML key to uint64 value to track

func Uint64Array

func Uint64Array(key string, defaultValue []uint64) *[]uint64

Uint64Array defines a TOML key to uint64 array value to track

func Uint64ArrayVar

func Uint64ArrayVar(ptr *[]uint64, key string, defaultValue []uint64)

Uint64ArrayVar defines a TOML key to uint64 array value to track, storing value in provided pointer

func Uint64Var

func Uint64Var(ptr *uint64, key string, defaultValue uint64)

Uint64Var defines a TOML key to uint64 value to track, storing value in provided pointer

Types

type Tree

type Tree map[string]interface{}

Tree is the config's key to tracked value pointer map. TOML values are parsed into here

func (Tree) Bool

func (c Tree) Bool(key string, defaultValue bool) *bool

Bool defines a TOML key to bool value to track

func (Tree) BoolArray

func (c Tree) BoolArray(key string, defaultValue []bool) *[]bool

BoolArray defines a TOML key to bool array value to track

func (Tree) BoolArrayVar

func (c Tree) BoolArrayVar(ptr *[]bool, key string, defaultValue []bool)

BoolArrayVar defines a TOML key to bool array value to track, storing value in provided pointer

func (Tree) BoolVar

func (c Tree) BoolVar(ptr *bool, key string, defaultValue bool)

BoolVar defines a TOML key to bool value to track, storing value in provided pointer

func (Tree) Duration

func (c Tree) Duration(key string, defaultValue time.Duration) *time.Duration

Duration defines a TOML key to time.Duration value to track

func (Tree) DurationArray

func (c Tree) DurationArray(key string, defaultValue []time.Duration) *[]time.Duration

DurationArray defines a TOML key to time.Duration array value to track

func (Tree) DurationArrayVar

func (c Tree) DurationArrayVar(ptr *[]time.Duration, key string, defaultValue []time.Duration)

DurationArrayVar defines a TOML key to time.Duration array value to track, storing value in provided pointer

func (Tree) DurationVar

func (c Tree) DurationVar(ptr *time.Duration, key string, defaultValue time.Duration)

DurationVar defines a TOML key to time.Duration value to track, storing value in provided pointer

func (Tree) Float64

func (c Tree) Float64(key string, defaultValue float64) *float64

Float64 defines a TOML key to float64 value to track

func (Tree) Float64Array

func (c Tree) Float64Array(key string, defaultValue []float64) *[]float64

Float64Array defines a TOML key to float64 array value to track

func (Tree) Float64ArrayVar

func (c Tree) Float64ArrayVar(ptr *[]float64, key string, defaultValue []float64)

Float64ArrayVar defines a TOML key to float64 array value to track, storing value in provided pointer

func (Tree) Float64Var

func (c Tree) Float64Var(ptr *float64, key string, defaultValue float64)

Float64Var defines a TOML key to float64 value to track, storing value in provided pointer

func (Tree) Int64

func (c Tree) Int64(key string, defaultValue int64) *int64

Int64 defines a TOML key to int64 value to track

func (Tree) Int64Array

func (c Tree) Int64Array(key string, defaultValue []int64) *[]int64

Int64Array defines a TOML key to int64 array value to track

func (Tree) Int64ArrayVar

func (c Tree) Int64ArrayVar(ptr *[]int64, key string, defaultValue []int64)

Int64ArrayVar defines a TOML key to int64 array value to track, storing value in provided pointer

func (Tree) Int64Var

func (c Tree) Int64Var(ptr *int64, key string, defaultValue int64)

Int64Var defines a TOML key to int64 value to track, storing value in provided pointer

func (Tree) Parse

func (c Tree) Parse(path string)

Parse attempts to parse the configuration file at path, panicking on undefined keys

func (Tree) ParseDefined

func (c Tree) ParseDefined(path string) (map[string]interface{}, error)

ParseDefined attempts to parse the configuration file at Path, returning a map of any undefined keys

func (Tree) String

func (c Tree) String(key string, defaultValue string) *string

String defines a TOML key to string value to track

func (Tree) StringArray

func (c Tree) StringArray(key string, defaultValue []string) *[]string

StringArray defines a TOML key to string array value to track

func (Tree) StringArrayVar

func (c Tree) StringArrayVar(ptr *[]string, key string, defaultValue []string)

StringArrayVar defines a TOML key to string array value to track, storing value in provided pointer

func (Tree) StringVar

func (c Tree) StringVar(ptr *string, key string, defaultValue string)

StringVar defines a TOML key to string value to track, storing value in provided pointer

func (Tree) Time

func (c Tree) Time(key string, defaultValue time.Time) *time.Time

Time defines a TOML key to time.Time value to track

func (Tree) TimeArray

func (c Tree) TimeArray(key string, defaultValue []time.Time) *[]time.Time

TimeArray defines a TOML key to time.Time array value to track

func (Tree) TimeArrayVar

func (c Tree) TimeArrayVar(ptr *[]time.Time, key string, defaultValue []time.Time)

TimeArrayVar defines a TOML key to time.Time array value to track, storing value in provided pointer

func (Tree) TimeVar

func (c Tree) TimeVar(ptr *time.Time, key string, defaultValue time.Time)

TimeVar defines a TOML key to time.Time value to track, storing value in provided pointer

func (Tree) Uint64

func (c Tree) Uint64(key string, defaultValue uint64) *uint64

Uint64 defines a TOML key to uint64 value to track

func (Tree) Uint64Array

func (c Tree) Uint64Array(key string, defaultValue []uint64) *[]uint64

Uint64Array defines a TOML key to uint64 array value to track

func (Tree) Uint64ArrayVar

func (c Tree) Uint64ArrayVar(ptr *[]uint64, key string, defaultValue []uint64)

Uint64ArrayVar defines a TOML key to uint64 array value to track, storing value in provided pointer

func (Tree) Uint64Var

func (c Tree) Uint64Var(ptr *uint64, key string, defaultValue uint64)

Uint64Var defines a TOML key to uint64 value to track, storing value in provided pointer

func (Tree) Wildcard

func (c Tree) Wildcard(key string, defaultValue map[string]interface{}, require bool, strict bool) *map[string](map[string]interface{})

Wildcard defines a TOML tree with expected keys to track. Strict mode: throws errors on undefined (extra) keys. Require mode: throws errors on missing keys

func (Tree) WildcardVar

func (c Tree) WildcardVar(ptr *map[string](map[string]interface{}), key string, defaultValue map[string]interface{}, require bool, strict bool)

WildcardVar defines a TOML tree with expected keys to track. Strict mode: throws errors on undefined (extra) keys. Require mode: throws errors on missing keys. Stores value in provided ptr

Jump to

Keyboard shortcuts

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