jsoncfg

package module
Version: v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: GPL-3.0 Imports: 5 Imported by: 4

README

jsoncfg

🍪 Buy me a cookie

Go Report Card

What is this?

This Go module allows you to read/write and get/set configuration options from/to a JSON file.

How to install

Open a terminal and run the following:

$ go get --ldflags="-s -w" --trimpath -u gitlab.com/mjwhitta/jsoncfg

Usage

package main

import (
    "fmt"

    "gitlab.com/mjwhitta/jsoncfg"
)

var config *jsoncfg.JSONCfg

func init() {
    // Create a jsoncfg object
    config = jsoncfg.New("/tmp/rc")

    // Or if you want changes to be written to disk immediately:
    // config = jsoncfg.NewAutosave("/tmp/rc")

    config.SetDefault(true, "a")
    config.SetDefault("asdf", "b")
    config.SetDefault(1234, "c")
    config.SetDefault([]string{"blah", "test"}, "d")
    config.SetDefault(
        map[string]interface{}{"float": 1.2, "int": 0},
        "e",
    )
    config.SaveDefault()
    config.Reset()
}

func main() {
    defer func() {
        if r := recover(); r != nil {
            fmt.Println(r.(error).Error())
        }
    }()

    var a bool
    var b string
    var c int64
    var d []string
    var e = map[string]interface{}{}
    var err error
    var f float64
    var keys []string

    fmt.Println(config.String())

    // Check if config has a key and print it
    if config.HasKey("a") {
        if a, err = config.MustGetBool("a"); err != nil {
            panic(err)
        }
        fmt.Printf("a = %v\n", a)
    }

    // Set new value (changes aren't written unless autosave was used)
    config.Set(false, "a")

    a = config.GetBool("a")
    fmt.Printf("a is now = %v\n", a)

    config.Reset()
    fmt.Println("Config reset")

    a = config.GetBool("a")
    fmt.Printf("a on disk still = %v\n", a)

    config.Set(false, "a")

    // Manually save changes
    config.Save()
    fmt.Println("Config saved")

    // More changes plus save
    config.Set("asdfasdf", "b")
    config.Set(4321, "c")
    config.Set("asdf", "d", 0)
    config.Set("asdf", "d", 1)
    config.Set([]string{"blah", "blah"}, "d")
    config.Save()

    b = config.GetString("b")
    c = config.GetInt64("c")
    d = config.GetStringArray("d")

    fmt.Printf("b = %s\n", b)
    fmt.Printf("c = %d\n", c)
    fmt.Printf("d = %v\n", d)

    // You can also reset changes (unless autosave was used)
    config.Set(true, "e", "bool")
    config.Set("test", "e", "string")
    config.Set(
        map[string]interface{}{"bool": true, "string": "test"},
        "e",
    )

    e = config.GetMap("e")
    fmt.Printf("e = %+v\n", e)

    config.Reset()
    fmt.Println("Config reset")

    e = config.GetMap("e")
    fmt.Printf("e = %+v\n", e)

    // Get nested keys
    f = config.GetFloat64("e", "float")
    fmt.Printf("e->float = %0.1f\n", f)

    // Only want to save the changes from default values?
    config.Set(false, "a")
    config.SaveDiff() // Diffs are calculated from last manual save

    // Reset to default values
    config.Default()
    config.Save()

    // Get sub-keys
    if keys, err = config.MustGetKeys("a"); err != nil {
        fmt.Println(err.Error())
    } else {
        fmt.Println(keys)
    }

    keys = config.GetKeys("d")
    fmt.Println(keys)
    keys = config.GetKeys("e")
    fmt.Println(keys)
}

Documentation

Overview

Code generated by scripts/generate_go_funcs; DO NOT EDIT.

Index

Constants

View Source
const Version = "1.4.6"

Version is the package version.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONCfg added in v1.1.9

type JSONCfg struct {
	File string
	// contains filtered or unexported fields
}

JSONCfg is a struct that handles a JSON formatted config file on disk. It contains the filename, the running config, the default config, and any changes from default. If autosave is true, changes are written to disk immediately.

func New

func New(file ...string) *JSONCfg

New will return a pointer to a new JSONCfg instance that requires manual calls to Save() to write the config to disk.

func NewAutosave

func NewAutosave(file ...string) *JSONCfg

NewAutosave will return a pointer to a new JSONCfg instance that is immediately written to disk on change.

func (*JSONCfg) Append added in v1.4.2

func (c *JSONCfg) Append(
	value interface{},
	keys ...interface{},
) error

Append will append the specified value to the specified key in the config, if it is an array.

func (*JSONCfg) AppendDefault added in v1.4.2

func (c *JSONCfg) AppendDefault(
	value interface{},
	keys ...interface{},
) error

AppendDefault will append the specified value to the specified key in the config, if it is an array. It will not write changes to disk ever and is intended to be used prior to SaveDefault().

func (*JSONCfg) Clear added in v1.1.9

func (c *JSONCfg) Clear()

Clear will erase the config.

func (*JSONCfg) Default added in v1.1.9

func (c *JSONCfg) Default() error

Default will return the config to a pre-configured default state.

func (*JSONCfg) Get added in v1.1.9

func (c *JSONCfg) Get(key ...interface{}) interface{}

Get will return the value for the specified key(s) as a interface{}.

func (*JSONCfg) GetArray added in v1.2.1

func (c *JSONCfg) GetArray(key ...interface{}) []interface{}

GetArray will return an array for the specified key(s) as a []interface{}.

func (*JSONCfg) GetBool added in v1.2.0

func (c *JSONCfg) GetBool(key ...interface{}) bool

GetBool will return the value for the specified key(s) as a bool.

func (*JSONCfg) GetBoolArray added in v1.2.0

func (c *JSONCfg) GetBoolArray(key ...interface{}) []bool

GetBoolArray will return an array for the specified key(s) as a []bool.

func (*JSONCfg) GetBoolMap added in v1.2.0

func (c *JSONCfg) GetBoolMap(key ...interface{}) map[string]bool

GetBoolMap will return a map for the specified key(s) as a map[string]bool.

func (*JSONCfg) GetDiff added in v1.1.9

func (c *JSONCfg) GetDiff(key ...interface{}) interface{}

GetDiff will return the value for the specified key(s) as a interface{}.

func (*JSONCfg) GetDiffArray added in v1.2.1

func (c *JSONCfg) GetDiffArray(key ...interface{}) []interface{}

GetDiffArray will return an array for the specified key(s) as a []interface{}.

func (*JSONCfg) GetDiffBool added in v1.2.0

func (c *JSONCfg) GetDiffBool(key ...interface{}) bool

GetDiffBool will return the value for the specified key(s) as a bool.

func (*JSONCfg) GetDiffBoolArray added in v1.2.0

func (c *JSONCfg) GetDiffBoolArray(key ...interface{}) []bool

GetDiffBoolArray will return an array for the specified key(s) as a []bool.

func (*JSONCfg) GetDiffBoolMap added in v1.2.0

func (c *JSONCfg) GetDiffBoolMap(key ...interface{}) map[string]bool

GetDiffBoolMap will return a map for the specified key(s) as a map[string]bool.

func (*JSONCfg) GetDiffFloat32 added in v1.2.0

func (c *JSONCfg) GetDiffFloat32(key ...interface{}) float32

GetDiffFloat32 will return the value for the specified key(s) as a float32.

func (*JSONCfg) GetDiffFloat32Array added in v1.2.0

func (c *JSONCfg) GetDiffFloat32Array(key ...interface{}) []float32

GetDiffFloat32Array will return an array for the specified key(s) as a []float32.

func (*JSONCfg) GetDiffFloat32Map added in v1.2.0

func (c *JSONCfg) GetDiffFloat32Map(key ...interface{}) map[string]float32

GetDiffFloat32Map will return a map for the specified key(s) as a map[string]float32.

func (*JSONCfg) GetDiffFloat64 added in v1.2.0

func (c *JSONCfg) GetDiffFloat64(key ...interface{}) float64

GetDiffFloat64 will return the value for the specified key(s) as a float64.

func (*JSONCfg) GetDiffFloat64Array added in v1.2.0

func (c *JSONCfg) GetDiffFloat64Array(key ...interface{}) []float64

GetDiffFloat64Array will return an array for the specified key(s) as a []float64.

func (*JSONCfg) GetDiffFloat64Map added in v1.2.0

func (c *JSONCfg) GetDiffFloat64Map(key ...interface{}) map[string]float64

GetDiffFloat64Map will return a map for the specified key(s) as a map[string]float64.

func (*JSONCfg) GetDiffInt added in v1.2.0

func (c *JSONCfg) GetDiffInt(key ...interface{}) int

GetDiffInt will return the value for the specified key(s) as a int.

func (*JSONCfg) GetDiffInt16 added in v1.2.0

func (c *JSONCfg) GetDiffInt16(key ...interface{}) int16

GetDiffInt16 will return the value for the specified key(s) as a int16.

func (*JSONCfg) GetDiffInt16Array added in v1.2.0

func (c *JSONCfg) GetDiffInt16Array(key ...interface{}) []int16

GetDiffInt16Array will return an array for the specified key(s) as a []int16.

func (*JSONCfg) GetDiffInt16Map added in v1.2.0

func (c *JSONCfg) GetDiffInt16Map(key ...interface{}) map[string]int16

GetDiffInt16Map will return a map for the specified key(s) as a map[string]int16.

func (*JSONCfg) GetDiffInt32 added in v1.2.0

func (c *JSONCfg) GetDiffInt32(key ...interface{}) int32

GetDiffInt32 will return the value for the specified key(s) as a int32.

func (*JSONCfg) GetDiffInt32Array added in v1.2.0

func (c *JSONCfg) GetDiffInt32Array(key ...interface{}) []int32

GetDiffInt32Array will return an array for the specified key(s) as a []int32.

func (*JSONCfg) GetDiffInt32Map added in v1.2.0

func (c *JSONCfg) GetDiffInt32Map(key ...interface{}) map[string]int32

GetDiffInt32Map will return a map for the specified key(s) as a map[string]int32.

func (*JSONCfg) GetDiffInt64 added in v1.2.0

func (c *JSONCfg) GetDiffInt64(key ...interface{}) int64

GetDiffInt64 will return the value for the specified key(s) as a int64.

func (*JSONCfg) GetDiffInt64Array added in v1.2.0

func (c *JSONCfg) GetDiffInt64Array(key ...interface{}) []int64

GetDiffInt64Array will return an array for the specified key(s) as a []int64.

func (*JSONCfg) GetDiffInt64Map added in v1.2.0

func (c *JSONCfg) GetDiffInt64Map(key ...interface{}) map[string]int64

GetDiffInt64Map will return a map for the specified key(s) as a map[string]int64.

func (*JSONCfg) GetDiffIntArray added in v1.2.0

func (c *JSONCfg) GetDiffIntArray(key ...interface{}) []int

GetDiffIntArray will return an array for the specified key(s) as a []int.

func (*JSONCfg) GetDiffIntMap added in v1.2.0

func (c *JSONCfg) GetDiffIntMap(key ...interface{}) map[string]int

GetDiffIntMap will return a map for the specified key(s) as a map[string]int.

func (*JSONCfg) GetDiffMap added in v1.2.1

func (c *JSONCfg) GetDiffMap(key ...interface{}) map[string]interface{}

GetDiffMap will return a map for the specified key(s) as a map[string]interface{}.

func (*JSONCfg) GetDiffString added in v1.2.0

func (c *JSONCfg) GetDiffString(key ...interface{}) string

GetDiffString will return the value for the specified key(s) as a string.

func (*JSONCfg) GetDiffStringArray added in v1.2.0

func (c *JSONCfg) GetDiffStringArray(key ...interface{}) []string

GetDiffStringArray will return an array for the specified key(s) as a []string.

func (*JSONCfg) GetDiffStringMap added in v1.2.0

func (c *JSONCfg) GetDiffStringMap(key ...interface{}) map[string]string

GetDiffStringMap will return a map for the specified key(s) as a map[string]string.

func (*JSONCfg) GetDiffUint added in v1.2.0

func (c *JSONCfg) GetDiffUint(key ...interface{}) uint

GetDiffUint will return the value for the specified key(s) as a uint.

func (*JSONCfg) GetDiffUint16 added in v1.2.0

func (c *JSONCfg) GetDiffUint16(key ...interface{}) uint16

GetDiffUint16 will return the value for the specified key(s) as a uint16.

func (*JSONCfg) GetDiffUint16Array added in v1.2.0

func (c *JSONCfg) GetDiffUint16Array(key ...interface{}) []uint16

GetDiffUint16Array will return an array for the specified key(s) as a []uint16.

func (*JSONCfg) GetDiffUint16Map added in v1.2.0

func (c *JSONCfg) GetDiffUint16Map(key ...interface{}) map[string]uint16

GetDiffUint16Map will return a map for the specified key(s) as a map[string]uint16.

func (*JSONCfg) GetDiffUint32 added in v1.2.0

func (c *JSONCfg) GetDiffUint32(key ...interface{}) uint32

GetDiffUint32 will return the value for the specified key(s) as a uint32.

func (*JSONCfg) GetDiffUint32Array added in v1.2.0

func (c *JSONCfg) GetDiffUint32Array(key ...interface{}) []uint32

GetDiffUint32Array will return an array for the specified key(s) as a []uint32.

func (*JSONCfg) GetDiffUint32Map added in v1.2.0

func (c *JSONCfg) GetDiffUint32Map(key ...interface{}) map[string]uint32

GetDiffUint32Map will return a map for the specified key(s) as a map[string]uint32.

func (*JSONCfg) GetDiffUint64 added in v1.2.0

func (c *JSONCfg) GetDiffUint64(key ...interface{}) uint64

GetDiffUint64 will return the value for the specified key(s) as a uint64.

func (*JSONCfg) GetDiffUint64Array added in v1.2.0

func (c *JSONCfg) GetDiffUint64Array(key ...interface{}) []uint64

GetDiffUint64Array will return an array for the specified key(s) as a []uint64.

func (*JSONCfg) GetDiffUint64Map added in v1.2.0

func (c *JSONCfg) GetDiffUint64Map(key ...interface{}) map[string]uint64

GetDiffUint64Map will return a map for the specified key(s) as a map[string]uint64.

func (*JSONCfg) GetDiffUintArray added in v1.2.0

func (c *JSONCfg) GetDiffUintArray(key ...interface{}) []uint

GetDiffUintArray will return an array for the specified key(s) as a []uint.

func (*JSONCfg) GetDiffUintMap added in v1.2.0

func (c *JSONCfg) GetDiffUintMap(key ...interface{}) map[string]uint

GetDiffUintMap will return a map for the specified key(s) as a map[string]uint.

func (*JSONCfg) GetFloat32 added in v1.2.0

func (c *JSONCfg) GetFloat32(key ...interface{}) float32

GetFloat32 will return the value for the specified key(s) as a float32.

func (*JSONCfg) GetFloat32Array added in v1.2.0

func (c *JSONCfg) GetFloat32Array(key ...interface{}) []float32

GetFloat32Array will return an array for the specified key(s) as a []float32.

func (*JSONCfg) GetFloat32Map added in v1.2.0

func (c *JSONCfg) GetFloat32Map(key ...interface{}) map[string]float32

GetFloat32Map will return a map for the specified key(s) as a map[string]float32.

func (*JSONCfg) GetFloat64 added in v1.2.0

func (c *JSONCfg) GetFloat64(key ...interface{}) float64

GetFloat64 will return the value for the specified key(s) as a float64.

func (*JSONCfg) GetFloat64Array added in v1.2.0

func (c *JSONCfg) GetFloat64Array(key ...interface{}) []float64

GetFloat64Array will return an array for the specified key(s) as a []float64.

func (*JSONCfg) GetFloat64Map added in v1.2.0

func (c *JSONCfg) GetFloat64Map(key ...interface{}) map[string]float64

GetFloat64Map will return a map for the specified key(s) as a map[string]float64.

func (*JSONCfg) GetInt added in v1.2.0

func (c *JSONCfg) GetInt(key ...interface{}) int

GetInt will return the value for the specified key(s) as a int.

func (*JSONCfg) GetInt16 added in v1.2.0

func (c *JSONCfg) GetInt16(key ...interface{}) int16

GetInt16 will return the value for the specified key(s) as a int16.

func (*JSONCfg) GetInt16Array added in v1.2.0

func (c *JSONCfg) GetInt16Array(key ...interface{}) []int16

GetInt16Array will return an array for the specified key(s) as a []int16.

func (*JSONCfg) GetInt16Map added in v1.2.0

func (c *JSONCfg) GetInt16Map(key ...interface{}) map[string]int16

GetInt16Map will return a map for the specified key(s) as a map[string]int16.

func (*JSONCfg) GetInt32 added in v1.2.0

func (c *JSONCfg) GetInt32(key ...interface{}) int32

GetInt32 will return the value for the specified key(s) as a int32.

func (*JSONCfg) GetInt32Array added in v1.2.0

func (c *JSONCfg) GetInt32Array(key ...interface{}) []int32

GetInt32Array will return an array for the specified key(s) as a []int32.

func (*JSONCfg) GetInt32Map added in v1.2.0

func (c *JSONCfg) GetInt32Map(key ...interface{}) map[string]int32

GetInt32Map will return a map for the specified key(s) as a map[string]int32.

func (*JSONCfg) GetInt64 added in v1.2.0

func (c *JSONCfg) GetInt64(key ...interface{}) int64

GetInt64 will return the value for the specified key(s) as a int64.

func (*JSONCfg) GetInt64Array added in v1.2.0

func (c *JSONCfg) GetInt64Array(key ...interface{}) []int64

GetInt64Array will return an array for the specified key(s) as a []int64.

func (*JSONCfg) GetInt64Map added in v1.2.0

func (c *JSONCfg) GetInt64Map(key ...interface{}) map[string]int64

GetInt64Map will return a map for the specified key(s) as a map[string]int64.

func (*JSONCfg) GetIntArray added in v1.2.0

func (c *JSONCfg) GetIntArray(key ...interface{}) []int

GetIntArray will return an array for the specified key(s) as a []int.

func (*JSONCfg) GetIntMap added in v1.2.0

func (c *JSONCfg) GetIntMap(key ...interface{}) map[string]int

GetIntMap will return a map for the specified key(s) as a map[string]int.

func (*JSONCfg) GetKeys added in v1.3.2

func (c *JSONCfg) GetKeys(keys ...interface{}) []string

GetKeys will return a list of valid keys if the specified key returns an arry or map.

func (*JSONCfg) GetMap added in v1.2.1

func (c *JSONCfg) GetMap(key ...interface{}) map[string]interface{}

GetMap will return a map for the specified key(s) as a map[string]interface{}.

func (*JSONCfg) GetString added in v1.2.0

func (c *JSONCfg) GetString(key ...interface{}) string

GetString will return the value for the specified key(s) as a string.

func (*JSONCfg) GetStringArray added in v1.2.0

func (c *JSONCfg) GetStringArray(key ...interface{}) []string

GetStringArray will return an array for the specified key(s) as a []string.

func (*JSONCfg) GetStringMap added in v1.2.0

func (c *JSONCfg) GetStringMap(key ...interface{}) map[string]string

GetStringMap will return a map for the specified key(s) as a map[string]string.

func (*JSONCfg) GetUint added in v1.2.0

func (c *JSONCfg) GetUint(key ...interface{}) uint

GetUint will return the value for the specified key(s) as a uint.

func (*JSONCfg) GetUint16 added in v1.2.0

func (c *JSONCfg) GetUint16(key ...interface{}) uint16

GetUint16 will return the value for the specified key(s) as a uint16.

func (*JSONCfg) GetUint16Array added in v1.2.0

func (c *JSONCfg) GetUint16Array(key ...interface{}) []uint16

GetUint16Array will return an array for the specified key(s) as a []uint16.

func (*JSONCfg) GetUint16Map added in v1.2.0

func (c *JSONCfg) GetUint16Map(key ...interface{}) map[string]uint16

GetUint16Map will return a map for the specified key(s) as a map[string]uint16.

func (*JSONCfg) GetUint32 added in v1.2.0

func (c *JSONCfg) GetUint32(key ...interface{}) uint32

GetUint32 will return the value for the specified key(s) as a uint32.

func (*JSONCfg) GetUint32Array added in v1.2.0

func (c *JSONCfg) GetUint32Array(key ...interface{}) []uint32

GetUint32Array will return an array for the specified key(s) as a []uint32.

func (*JSONCfg) GetUint32Map added in v1.2.0

func (c *JSONCfg) GetUint32Map(key ...interface{}) map[string]uint32

GetUint32Map will return a map for the specified key(s) as a map[string]uint32.

func (*JSONCfg) GetUint64 added in v1.2.0

func (c *JSONCfg) GetUint64(key ...interface{}) uint64

GetUint64 will return the value for the specified key(s) as a uint64.

func (*JSONCfg) GetUint64Array added in v1.2.0

func (c *JSONCfg) GetUint64Array(key ...interface{}) []uint64

GetUint64Array will return an array for the specified key(s) as a []uint64.

func (*JSONCfg) GetUint64Map added in v1.2.0

func (c *JSONCfg) GetUint64Map(key ...interface{}) map[string]uint64

GetUint64Map will return a map for the specified key(s) as a map[string]uint64.

func (*JSONCfg) GetUintArray added in v1.2.0

func (c *JSONCfg) GetUintArray(key ...interface{}) []uint

GetUintArray will return an array for the specified key(s) as a []uint.

func (*JSONCfg) GetUintMap added in v1.2.0

func (c *JSONCfg) GetUintMap(key ...interface{}) map[string]uint

GetUintMap will return a map for the specified key(s) as a map[string]uint.

func (*JSONCfg) HasKey added in v1.3.2

func (c *JSONCfg) HasKey(keys ...interface{}) bool

HasKey will return true if the config has the specified key, false otherwise.

func (*JSONCfg) MustGet added in v1.4.0

func (c *JSONCfg) MustGet(key ...interface{}) (interface{}, error)

MustGet will return the value for the specified key(s) as a interface{}.

func (*JSONCfg) MustGetArray added in v1.4.0

func (c *JSONCfg) MustGetArray(
	key ...interface{},
) ([]interface{}, error)

MustGetArray will return an array for the specified key(s) as a []interface{}.

func (*JSONCfg) MustGetBool added in v1.4.0

func (c *JSONCfg) MustGetBool(key ...interface{}) (bool, error)

MustGetBool will return the value for the specified key(s) as a bool.

func (*JSONCfg) MustGetBoolArray added in v1.4.0

func (c *JSONCfg) MustGetBoolArray(
	key ...interface{},
) ([]bool, error)

MustGetBoolArray will return an array for the specified key(s) as a []bool.

func (*JSONCfg) MustGetBoolMap added in v1.4.0

func (c *JSONCfg) MustGetBoolMap(
	key ...interface{},
) (map[string]bool, error)

MustGetBoolMap will return a map for the specified key(s) as a map[string]bool.

func (*JSONCfg) MustGetDiff added in v1.4.0

func (c *JSONCfg) MustGetDiff(key ...interface{}) (interface{}, error)

MustGetDiff will return the value for the specified key(s) as a interface{}.

func (*JSONCfg) MustGetDiffArray added in v1.4.0

func (c *JSONCfg) MustGetDiffArray(
	key ...interface{},
) ([]interface{}, error)

MustGetDiffArray will return an array for the specified key(s) as a []interface{}.

func (*JSONCfg) MustGetDiffBool added in v1.4.0

func (c *JSONCfg) MustGetDiffBool(key ...interface{}) (bool, error)

MustGetDiffBool will return the value for the specified key(s) as a bool.

func (*JSONCfg) MustGetDiffBoolArray added in v1.4.0

func (c *JSONCfg) MustGetDiffBoolArray(
	key ...interface{},
) ([]bool, error)

MustGetDiffBoolArray will return an array for the specified key(s) as a []bool.

func (*JSONCfg) MustGetDiffBoolMap added in v1.4.0

func (c *JSONCfg) MustGetDiffBoolMap(
	key ...interface{},
) (map[string]bool, error)

MustGetDiffBoolMap will return a map for the specified key(s) as a map[string]bool.

func (*JSONCfg) MustGetDiffFloat32 added in v1.4.0

func (c *JSONCfg) MustGetDiffFloat32(key ...interface{}) (float32, error)

MustGetDiffFloat32 will return the value for the specified key(s) as a float32.

func (*JSONCfg) MustGetDiffFloat32Array added in v1.4.0

func (c *JSONCfg) MustGetDiffFloat32Array(
	key ...interface{},
) ([]float32, error)

MustGetDiffFloat32Array will return an array for the specified key(s) as a []float32.

func (*JSONCfg) MustGetDiffFloat32Map added in v1.4.0

func (c *JSONCfg) MustGetDiffFloat32Map(
	key ...interface{},
) (map[string]float32, error)

MustGetDiffFloat32Map will return a map for the specified key(s) as a map[string]float32.

func (*JSONCfg) MustGetDiffFloat64 added in v1.4.0

func (c *JSONCfg) MustGetDiffFloat64(key ...interface{}) (float64, error)

MustGetDiffFloat64 will return the value for the specified key(s) as a float64.

func (*JSONCfg) MustGetDiffFloat64Array added in v1.4.0

func (c *JSONCfg) MustGetDiffFloat64Array(
	key ...interface{},
) ([]float64, error)

MustGetDiffFloat64Array will return an array for the specified key(s) as a []float64.

func (*JSONCfg) MustGetDiffFloat64Map added in v1.4.0

func (c *JSONCfg) MustGetDiffFloat64Map(
	key ...interface{},
) (map[string]float64, error)

MustGetDiffFloat64Map will return a map for the specified key(s) as a map[string]float64.

func (*JSONCfg) MustGetDiffInt added in v1.4.0

func (c *JSONCfg) MustGetDiffInt(key ...interface{}) (int, error)

MustGetDiffInt will return the value for the specified key(s) as a int.

func (*JSONCfg) MustGetDiffInt16 added in v1.4.0

func (c *JSONCfg) MustGetDiffInt16(key ...interface{}) (int16, error)

MustGetDiffInt16 will return the value for the specified key(s) as a int16.

func (*JSONCfg) MustGetDiffInt16Array added in v1.4.0

func (c *JSONCfg) MustGetDiffInt16Array(
	key ...interface{},
) ([]int16, error)

MustGetDiffInt16Array will return an array for the specified key(s) as a []int16.

func (*JSONCfg) MustGetDiffInt16Map added in v1.4.0

func (c *JSONCfg) MustGetDiffInt16Map(
	key ...interface{},
) (map[string]int16, error)

MustGetDiffInt16Map will return a map for the specified key(s) as a map[string]int16.

func (*JSONCfg) MustGetDiffInt32 added in v1.4.0

func (c *JSONCfg) MustGetDiffInt32(key ...interface{}) (int32, error)

MustGetDiffInt32 will return the value for the specified key(s) as a int32.

func (*JSONCfg) MustGetDiffInt32Array added in v1.4.0

func (c *JSONCfg) MustGetDiffInt32Array(
	key ...interface{},
) ([]int32, error)

MustGetDiffInt32Array will return an array for the specified key(s) as a []int32.

func (*JSONCfg) MustGetDiffInt32Map added in v1.4.0

func (c *JSONCfg) MustGetDiffInt32Map(
	key ...interface{},
) (map[string]int32, error)

MustGetDiffInt32Map will return a map for the specified key(s) as a map[string]int32.

func (*JSONCfg) MustGetDiffInt64 added in v1.4.0

func (c *JSONCfg) MustGetDiffInt64(key ...interface{}) (int64, error)

MustGetDiffInt64 will return the value for the specified key(s) as a int64.

func (*JSONCfg) MustGetDiffInt64Array added in v1.4.0

func (c *JSONCfg) MustGetDiffInt64Array(
	key ...interface{},
) ([]int64, error)

MustGetDiffInt64Array will return an array for the specified key(s) as a []int64.

func (*JSONCfg) MustGetDiffInt64Map added in v1.4.0

func (c *JSONCfg) MustGetDiffInt64Map(
	key ...interface{},
) (map[string]int64, error)

MustGetDiffInt64Map will return a map for the specified key(s) as a map[string]int64.

func (*JSONCfg) MustGetDiffIntArray added in v1.4.0

func (c *JSONCfg) MustGetDiffIntArray(
	key ...interface{},
) ([]int, error)

MustGetDiffIntArray will return an array for the specified key(s) as a []int.

func (*JSONCfg) MustGetDiffIntMap added in v1.4.0

func (c *JSONCfg) MustGetDiffIntMap(
	key ...interface{},
) (map[string]int, error)

MustGetDiffIntMap will return a map for the specified key(s) as a map[string]int.

func (*JSONCfg) MustGetDiffMap added in v1.4.0

func (c *JSONCfg) MustGetDiffMap(
	key ...interface{},
) (map[string]interface{}, error)

MustGetDiffMap will return a map for the specified key(s) as a map[string]interface{}.

func (*JSONCfg) MustGetDiffString added in v1.4.0

func (c *JSONCfg) MustGetDiffString(key ...interface{}) (string, error)

MustGetDiffString will return the value for the specified key(s) as a string.

func (*JSONCfg) MustGetDiffStringArray added in v1.4.0

func (c *JSONCfg) MustGetDiffStringArray(
	key ...interface{},
) ([]string, error)

MustGetDiffStringArray will return an array for the specified key(s) as a []string.

func (*JSONCfg) MustGetDiffStringMap added in v1.4.0

func (c *JSONCfg) MustGetDiffStringMap(
	key ...interface{},
) (map[string]string, error)

MustGetDiffStringMap will return a map for the specified key(s) as a map[string]string.

func (*JSONCfg) MustGetDiffUint added in v1.4.0

func (c *JSONCfg) MustGetDiffUint(key ...interface{}) (uint, error)

MustGetDiffUint will return the value for the specified key(s) as a uint.

func (*JSONCfg) MustGetDiffUint16 added in v1.4.0

func (c *JSONCfg) MustGetDiffUint16(key ...interface{}) (uint16, error)

MustGetDiffUint16 will return the value for the specified key(s) as a uint16.

func (*JSONCfg) MustGetDiffUint16Array added in v1.4.0

func (c *JSONCfg) MustGetDiffUint16Array(
	key ...interface{},
) ([]uint16, error)

MustGetDiffUint16Array will return an array for the specified key(s) as a []uint16.

func (*JSONCfg) MustGetDiffUint16Map added in v1.4.0

func (c *JSONCfg) MustGetDiffUint16Map(
	key ...interface{},
) (map[string]uint16, error)

MustGetDiffUint16Map will return a map for the specified key(s) as a map[string]uint16.

func (*JSONCfg) MustGetDiffUint32 added in v1.4.0

func (c *JSONCfg) MustGetDiffUint32(key ...interface{}) (uint32, error)

MustGetDiffUint32 will return the value for the specified key(s) as a uint32.

func (*JSONCfg) MustGetDiffUint32Array added in v1.4.0

func (c *JSONCfg) MustGetDiffUint32Array(
	key ...interface{},
) ([]uint32, error)

MustGetDiffUint32Array will return an array for the specified key(s) as a []uint32.

func (*JSONCfg) MustGetDiffUint32Map added in v1.4.0

func (c *JSONCfg) MustGetDiffUint32Map(
	key ...interface{},
) (map[string]uint32, error)

MustGetDiffUint32Map will return a map for the specified key(s) as a map[string]uint32.

func (*JSONCfg) MustGetDiffUint64 added in v1.4.0

func (c *JSONCfg) MustGetDiffUint64(key ...interface{}) (uint64, error)

MustGetDiffUint64 will return the value for the specified key(s) as a uint64.

func (*JSONCfg) MustGetDiffUint64Array added in v1.4.0

func (c *JSONCfg) MustGetDiffUint64Array(
	key ...interface{},
) ([]uint64, error)

MustGetDiffUint64Array will return an array for the specified key(s) as a []uint64.

func (*JSONCfg) MustGetDiffUint64Map added in v1.4.0

func (c *JSONCfg) MustGetDiffUint64Map(
	key ...interface{},
) (map[string]uint64, error)

MustGetDiffUint64Map will return a map for the specified key(s) as a map[string]uint64.

func (*JSONCfg) MustGetDiffUintArray added in v1.4.0

func (c *JSONCfg) MustGetDiffUintArray(
	key ...interface{},
) ([]uint, error)

MustGetDiffUintArray will return an array for the specified key(s) as a []uint.

func (*JSONCfg) MustGetDiffUintMap added in v1.4.0

func (c *JSONCfg) MustGetDiffUintMap(
	key ...interface{},
) (map[string]uint, error)

MustGetDiffUintMap will return a map for the specified key(s) as a map[string]uint.

func (*JSONCfg) MustGetFloat32 added in v1.4.0

func (c *JSONCfg) MustGetFloat32(key ...interface{}) (float32, error)

MustGetFloat32 will return the value for the specified key(s) as a float32.

func (*JSONCfg) MustGetFloat32Array added in v1.4.0

func (c *JSONCfg) MustGetFloat32Array(
	key ...interface{},
) ([]float32, error)

MustGetFloat32Array will return an array for the specified key(s) as a []float32.

func (*JSONCfg) MustGetFloat32Map added in v1.4.0

func (c *JSONCfg) MustGetFloat32Map(
	key ...interface{},
) (map[string]float32, error)

MustGetFloat32Map will return a map for the specified key(s) as a map[string]float32.

func (*JSONCfg) MustGetFloat64 added in v1.4.0

func (c *JSONCfg) MustGetFloat64(key ...interface{}) (float64, error)

MustGetFloat64 will return the value for the specified key(s) as a float64.

func (*JSONCfg) MustGetFloat64Array added in v1.4.0

func (c *JSONCfg) MustGetFloat64Array(
	key ...interface{},
) ([]float64, error)

MustGetFloat64Array will return an array for the specified key(s) as a []float64.

func (*JSONCfg) MustGetFloat64Map added in v1.4.0

func (c *JSONCfg) MustGetFloat64Map(
	key ...interface{},
) (map[string]float64, error)

MustGetFloat64Map will return a map for the specified key(s) as a map[string]float64.

func (*JSONCfg) MustGetInt added in v1.4.0

func (c *JSONCfg) MustGetInt(key ...interface{}) (int, error)

MustGetInt will return the value for the specified key(s) as a int.

func (*JSONCfg) MustGetInt16 added in v1.4.0

func (c *JSONCfg) MustGetInt16(key ...interface{}) (int16, error)

MustGetInt16 will return the value for the specified key(s) as a int16.

func (*JSONCfg) MustGetInt16Array added in v1.4.0

func (c *JSONCfg) MustGetInt16Array(
	key ...interface{},
) ([]int16, error)

MustGetInt16Array will return an array for the specified key(s) as a []int16.

func (*JSONCfg) MustGetInt16Map added in v1.4.0

func (c *JSONCfg) MustGetInt16Map(
	key ...interface{},
) (map[string]int16, error)

MustGetInt16Map will return a map for the specified key(s) as a map[string]int16.

func (*JSONCfg) MustGetInt32 added in v1.4.0

func (c *JSONCfg) MustGetInt32(key ...interface{}) (int32, error)

MustGetInt32 will return the value for the specified key(s) as a int32.

func (*JSONCfg) MustGetInt32Array added in v1.4.0

func (c *JSONCfg) MustGetInt32Array(
	key ...interface{},
) ([]int32, error)

MustGetInt32Array will return an array for the specified key(s) as a []int32.

func (*JSONCfg) MustGetInt32Map added in v1.4.0

func (c *JSONCfg) MustGetInt32Map(
	key ...interface{},
) (map[string]int32, error)

MustGetInt32Map will return a map for the specified key(s) as a map[string]int32.

func (*JSONCfg) MustGetInt64 added in v1.4.0

func (c *JSONCfg) MustGetInt64(key ...interface{}) (int64, error)

MustGetInt64 will return the value for the specified key(s) as a int64.

func (*JSONCfg) MustGetInt64Array added in v1.4.0

func (c *JSONCfg) MustGetInt64Array(
	key ...interface{},
) ([]int64, error)

MustGetInt64Array will return an array for the specified key(s) as a []int64.

func (*JSONCfg) MustGetInt64Map added in v1.4.0

func (c *JSONCfg) MustGetInt64Map(
	key ...interface{},
) (map[string]int64, error)

MustGetInt64Map will return a map for the specified key(s) as a map[string]int64.

func (*JSONCfg) MustGetIntArray added in v1.4.0

func (c *JSONCfg) MustGetIntArray(
	key ...interface{},
) ([]int, error)

MustGetIntArray will return an array for the specified key(s) as a []int.

func (*JSONCfg) MustGetIntMap added in v1.4.0

func (c *JSONCfg) MustGetIntMap(
	key ...interface{},
) (map[string]int, error)

MustGetIntMap will return a map for the specified key(s) as a map[string]int.

func (*JSONCfg) MustGetKeys added in v1.4.0

func (c *JSONCfg) MustGetKeys(keys ...interface{}) ([]string, error)

MustGetKeys will return a list of valid keys if the specified key returns an arry or map.

func (*JSONCfg) MustGetMap added in v1.4.0

func (c *JSONCfg) MustGetMap(
	key ...interface{},
) (map[string]interface{}, error)

MustGetMap will return a map for the specified key(s) as a map[string]interface{}.

func (*JSONCfg) MustGetString added in v1.4.0

func (c *JSONCfg) MustGetString(key ...interface{}) (string, error)

MustGetString will return the value for the specified key(s) as a string.

func (*JSONCfg) MustGetStringArray added in v1.4.0

func (c *JSONCfg) MustGetStringArray(
	key ...interface{},
) ([]string, error)

MustGetStringArray will return an array for the specified key(s) as a []string.

func (*JSONCfg) MustGetStringMap added in v1.4.0

func (c *JSONCfg) MustGetStringMap(
	key ...interface{},
) (map[string]string, error)

MustGetStringMap will return a map for the specified key(s) as a map[string]string.

func (*JSONCfg) MustGetUint added in v1.4.0

func (c *JSONCfg) MustGetUint(key ...interface{}) (uint, error)

MustGetUint will return the value for the specified key(s) as a uint.

func (*JSONCfg) MustGetUint16 added in v1.4.0

func (c *JSONCfg) MustGetUint16(key ...interface{}) (uint16, error)

MustGetUint16 will return the value for the specified key(s) as a uint16.

func (*JSONCfg) MustGetUint16Array added in v1.4.0

func (c *JSONCfg) MustGetUint16Array(
	key ...interface{},
) ([]uint16, error)

MustGetUint16Array will return an array for the specified key(s) as a []uint16.

func (*JSONCfg) MustGetUint16Map added in v1.4.0

func (c *JSONCfg) MustGetUint16Map(
	key ...interface{},
) (map[string]uint16, error)

MustGetUint16Map will return a map for the specified key(s) as a map[string]uint16.

func (*JSONCfg) MustGetUint32 added in v1.4.0

func (c *JSONCfg) MustGetUint32(key ...interface{}) (uint32, error)

MustGetUint32 will return the value for the specified key(s) as a uint32.

func (*JSONCfg) MustGetUint32Array added in v1.4.0

func (c *JSONCfg) MustGetUint32Array(
	key ...interface{},
) ([]uint32, error)

MustGetUint32Array will return an array for the specified key(s) as a []uint32.

func (*JSONCfg) MustGetUint32Map added in v1.4.0

func (c *JSONCfg) MustGetUint32Map(
	key ...interface{},
) (map[string]uint32, error)

MustGetUint32Map will return a map for the specified key(s) as a map[string]uint32.

func (*JSONCfg) MustGetUint64 added in v1.4.0

func (c *JSONCfg) MustGetUint64(key ...interface{}) (uint64, error)

MustGetUint64 will return the value for the specified key(s) as a uint64.

func (*JSONCfg) MustGetUint64Array added in v1.4.0

func (c *JSONCfg) MustGetUint64Array(
	key ...interface{},
) ([]uint64, error)

MustGetUint64Array will return an array for the specified key(s) as a []uint64.

func (*JSONCfg) MustGetUint64Map added in v1.4.0

func (c *JSONCfg) MustGetUint64Map(
	key ...interface{},
) (map[string]uint64, error)

MustGetUint64Map will return a map for the specified key(s) as a map[string]uint64.

func (*JSONCfg) MustGetUintArray added in v1.4.0

func (c *JSONCfg) MustGetUintArray(
	key ...interface{},
) ([]uint, error)

MustGetUintArray will return an array for the specified key(s) as a []uint.

func (*JSONCfg) MustGetUintMap added in v1.4.0

func (c *JSONCfg) MustGetUintMap(
	key ...interface{},
) (map[string]uint, error)

MustGetUintMap will return a map for the specified key(s) as a map[string]uint.

func (*JSONCfg) Reset added in v1.1.9

func (c *JSONCfg) Reset() error

Reset will read the config from disk, erasing any unsaved changes.

func (*JSONCfg) Save added in v1.1.9

func (c *JSONCfg) Save() error

Save will save any unsaved changes to disk.

func (*JSONCfg) SaveDefault added in v1.1.9

func (c *JSONCfg) SaveDefault() error

SaveDefault will save the default map for use by Default().

func (*JSONCfg) SaveDiff added in v1.1.9

func (c *JSONCfg) SaveDiff() error

SaveDiff will save only the changes from default to disk.

func (*JSONCfg) Set added in v1.1.9

func (c *JSONCfg) Set(value interface{}, keys ...interface{}) error

Set will set the specified value for the specified key in the config.

func (*JSONCfg) SetDefault added in v1.1.9

func (c *JSONCfg) SetDefault(
	value interface{},
	keys ...interface{},
) error

SetDefault will set the specified value for the specified key in the config. It will not write changes to disk ever and is intended to be used prior to SaveDefault().

func (*JSONCfg) String added in v1.2.11

func (c *JSONCfg) String() string

String will return a string representation of a config.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL