jsoncfg

package module
v1.6.13 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: GPL-3.0 Imports: 5 Imported by: 3

README

jsoncfg

Yum

Go Report Card GitHub Workflow Status License

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 github.com/mjwhitta/jsoncfg

Usage

package main

import (
    "fmt"

    "github.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]any{"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]any{}
    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]any{"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 genfuncs; DO NOT EDIT.

Index

Constants

View Source
const Version string = "1.6.13"

Version is the package version.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONCfg

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

func (c *JSONCfg) Append(value any, keys ...any) error

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

func (*JSONCfg) AppendDefault

func (c *JSONCfg) AppendDefault(value any, keys ...any) 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

func (c *JSONCfg) Clear()

Clear will erase the config.

func (*JSONCfg) Default

func (c *JSONCfg) Default() error

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

func (*JSONCfg) Get

func (c *JSONCfg) Get(key ...any) any

Get will return the value for the specified key(s) as a any.

func (*JSONCfg) GetArray

func (c *JSONCfg) GetArray(key ...any) []any

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

func (*JSONCfg) GetBool

func (c *JSONCfg) GetBool(key ...any) bool

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

func (*JSONCfg) GetBoolArray

func (c *JSONCfg) GetBoolArray(key ...any) []bool

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

func (*JSONCfg) GetBoolMap

func (c *JSONCfg) GetBoolMap(key ...any) map[string]bool

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

func (*JSONCfg) GetDiff

func (c *JSONCfg) GetDiff(key ...any) any

GetDiff will return the value for the specified key(s) as a any.

func (*JSONCfg) GetDiffArray

func (c *JSONCfg) GetDiffArray(key ...any) []any

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

func (*JSONCfg) GetDiffBool

func (c *JSONCfg) GetDiffBool(key ...any) bool

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

func (*JSONCfg) GetDiffBoolArray

func (c *JSONCfg) GetDiffBoolArray(key ...any) []bool

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

func (*JSONCfg) GetDiffBoolMap

func (c *JSONCfg) GetDiffBoolMap(key ...any) map[string]bool

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

func (*JSONCfg) GetDiffFloat32

func (c *JSONCfg) GetDiffFloat32(key ...any) float32

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

func (*JSONCfg) GetDiffFloat32Array

func (c *JSONCfg) GetDiffFloat32Array(key ...any) []float32

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

func (*JSONCfg) GetDiffFloat32Map

func (c *JSONCfg) GetDiffFloat32Map(key ...any) map[string]float32

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

func (*JSONCfg) GetDiffFloat64

func (c *JSONCfg) GetDiffFloat64(key ...any) float64

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

func (*JSONCfg) GetDiffFloat64Array

func (c *JSONCfg) GetDiffFloat64Array(key ...any) []float64

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

func (*JSONCfg) GetDiffFloat64Map

func (c *JSONCfg) GetDiffFloat64Map(key ...any) map[string]float64

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

func (*JSONCfg) GetDiffInt

func (c *JSONCfg) GetDiffInt(key ...any) int

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

func (*JSONCfg) GetDiffInt16

func (c *JSONCfg) GetDiffInt16(key ...any) int16

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

func (*JSONCfg) GetDiffInt16Array

func (c *JSONCfg) GetDiffInt16Array(key ...any) []int16

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

func (*JSONCfg) GetDiffInt16Map

func (c *JSONCfg) GetDiffInt16Map(key ...any) map[string]int16

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

func (*JSONCfg) GetDiffInt32

func (c *JSONCfg) GetDiffInt32(key ...any) int32

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

func (*JSONCfg) GetDiffInt32Array

func (c *JSONCfg) GetDiffInt32Array(key ...any) []int32

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

func (*JSONCfg) GetDiffInt32Map

func (c *JSONCfg) GetDiffInt32Map(key ...any) map[string]int32

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

func (*JSONCfg) GetDiffInt64

func (c *JSONCfg) GetDiffInt64(key ...any) int64

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

func (*JSONCfg) GetDiffInt64Array

func (c *JSONCfg) GetDiffInt64Array(key ...any) []int64

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

func (*JSONCfg) GetDiffInt64Map

func (c *JSONCfg) GetDiffInt64Map(key ...any) map[string]int64

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

func (*JSONCfg) GetDiffIntArray

func (c *JSONCfg) GetDiffIntArray(key ...any) []int

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

func (*JSONCfg) GetDiffIntMap

func (c *JSONCfg) GetDiffIntMap(key ...any) map[string]int

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

func (*JSONCfg) GetDiffMap

func (c *JSONCfg) GetDiffMap(key ...any) map[string]any

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

func (*JSONCfg) GetDiffString

func (c *JSONCfg) GetDiffString(key ...any) string

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

func (*JSONCfg) GetDiffStringArray

func (c *JSONCfg) GetDiffStringArray(key ...any) []string

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

func (*JSONCfg) GetDiffStringMap

func (c *JSONCfg) GetDiffStringMap(key ...any) map[string]string

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

func (*JSONCfg) GetDiffUint

func (c *JSONCfg) GetDiffUint(key ...any) uint

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

func (*JSONCfg) GetDiffUint16

func (c *JSONCfg) GetDiffUint16(key ...any) uint16

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

func (*JSONCfg) GetDiffUint16Array

func (c *JSONCfg) GetDiffUint16Array(key ...any) []uint16

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

func (*JSONCfg) GetDiffUint16Map

func (c *JSONCfg) GetDiffUint16Map(key ...any) map[string]uint16

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

func (*JSONCfg) GetDiffUint32

func (c *JSONCfg) GetDiffUint32(key ...any) uint32

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

func (*JSONCfg) GetDiffUint32Array

func (c *JSONCfg) GetDiffUint32Array(key ...any) []uint32

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

func (*JSONCfg) GetDiffUint32Map

func (c *JSONCfg) GetDiffUint32Map(key ...any) map[string]uint32

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

func (*JSONCfg) GetDiffUint64

func (c *JSONCfg) GetDiffUint64(key ...any) uint64

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

func (*JSONCfg) GetDiffUint64Array

func (c *JSONCfg) GetDiffUint64Array(key ...any) []uint64

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

func (*JSONCfg) GetDiffUint64Map

func (c *JSONCfg) GetDiffUint64Map(key ...any) map[string]uint64

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

func (*JSONCfg) GetDiffUintArray

func (c *JSONCfg) GetDiffUintArray(key ...any) []uint

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

func (*JSONCfg) GetDiffUintMap

func (c *JSONCfg) GetDiffUintMap(key ...any) map[string]uint

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

func (*JSONCfg) GetFloat32

func (c *JSONCfg) GetFloat32(key ...any) float32

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

func (*JSONCfg) GetFloat32Array

func (c *JSONCfg) GetFloat32Array(key ...any) []float32

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

func (*JSONCfg) GetFloat32Map

func (c *JSONCfg) GetFloat32Map(key ...any) map[string]float32

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

func (*JSONCfg) GetFloat64

func (c *JSONCfg) GetFloat64(key ...any) float64

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

func (*JSONCfg) GetFloat64Array

func (c *JSONCfg) GetFloat64Array(key ...any) []float64

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

func (*JSONCfg) GetFloat64Map

func (c *JSONCfg) GetFloat64Map(key ...any) map[string]float64

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

func (*JSONCfg) GetInt

func (c *JSONCfg) GetInt(key ...any) int

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

func (*JSONCfg) GetInt16

func (c *JSONCfg) GetInt16(key ...any) int16

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

func (*JSONCfg) GetInt16Array

func (c *JSONCfg) GetInt16Array(key ...any) []int16

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

func (*JSONCfg) GetInt16Map

func (c *JSONCfg) GetInt16Map(key ...any) map[string]int16

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

func (*JSONCfg) GetInt32

func (c *JSONCfg) GetInt32(key ...any) int32

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

func (*JSONCfg) GetInt32Array

func (c *JSONCfg) GetInt32Array(key ...any) []int32

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

func (*JSONCfg) GetInt32Map

func (c *JSONCfg) GetInt32Map(key ...any) map[string]int32

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

func (*JSONCfg) GetInt64

func (c *JSONCfg) GetInt64(key ...any) int64

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

func (*JSONCfg) GetInt64Array

func (c *JSONCfg) GetInt64Array(key ...any) []int64

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

func (*JSONCfg) GetInt64Map

func (c *JSONCfg) GetInt64Map(key ...any) map[string]int64

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

func (*JSONCfg) GetIntArray

func (c *JSONCfg) GetIntArray(key ...any) []int

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

func (*JSONCfg) GetIntMap

func (c *JSONCfg) GetIntMap(key ...any) map[string]int

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

func (*JSONCfg) GetKeys

func (c *JSONCfg) GetKeys(keys ...any) []string

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

func (*JSONCfg) GetMap

func (c *JSONCfg) GetMap(key ...any) map[string]any

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

func (*JSONCfg) GetString

func (c *JSONCfg) GetString(key ...any) string

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

func (*JSONCfg) GetStringArray

func (c *JSONCfg) GetStringArray(key ...any) []string

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

func (*JSONCfg) GetStringMap

func (c *JSONCfg) GetStringMap(key ...any) map[string]string

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

func (*JSONCfg) GetUint

func (c *JSONCfg) GetUint(key ...any) uint

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

func (*JSONCfg) GetUint16

func (c *JSONCfg) GetUint16(key ...any) uint16

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

func (*JSONCfg) GetUint16Array

func (c *JSONCfg) GetUint16Array(key ...any) []uint16

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

func (*JSONCfg) GetUint16Map

func (c *JSONCfg) GetUint16Map(key ...any) map[string]uint16

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

func (*JSONCfg) GetUint32

func (c *JSONCfg) GetUint32(key ...any) uint32

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

func (*JSONCfg) GetUint32Array

func (c *JSONCfg) GetUint32Array(key ...any) []uint32

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

func (*JSONCfg) GetUint32Map

func (c *JSONCfg) GetUint32Map(key ...any) map[string]uint32

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

func (*JSONCfg) GetUint64

func (c *JSONCfg) GetUint64(key ...any) uint64

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

func (*JSONCfg) GetUint64Array

func (c *JSONCfg) GetUint64Array(key ...any) []uint64

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

func (*JSONCfg) GetUint64Map

func (c *JSONCfg) GetUint64Map(key ...any) map[string]uint64

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

func (*JSONCfg) GetUintArray

func (c *JSONCfg) GetUintArray(key ...any) []uint

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

func (*JSONCfg) GetUintMap

func (c *JSONCfg) GetUintMap(key ...any) map[string]uint

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

func (*JSONCfg) HasKey

func (c *JSONCfg) HasKey(keys ...any) bool

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

func (*JSONCfg) MustGet

func (c *JSONCfg) MustGet(key ...any) (any, error)

MustGet will return the value for the specified key(s) as a any.

func (*JSONCfg) MustGetArray

func (c *JSONCfg) MustGetArray(key ...any) ([]any, error)

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

func (*JSONCfg) MustGetBool

func (c *JSONCfg) MustGetBool(key ...any) (bool, error)

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

func (*JSONCfg) MustGetBoolArray

func (c *JSONCfg) MustGetBoolArray(key ...any) ([]bool, error)

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

func (*JSONCfg) MustGetBoolMap

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

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

func (*JSONCfg) MustGetDiff

func (c *JSONCfg) MustGetDiff(key ...any) (any, error)

MustGetDiff will return the value for the specified key(s) as a any.

func (*JSONCfg) MustGetDiffArray

func (c *JSONCfg) MustGetDiffArray(key ...any) ([]any, error)

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

func (*JSONCfg) MustGetDiffBool

func (c *JSONCfg) MustGetDiffBool(key ...any) (bool, error)

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

func (*JSONCfg) MustGetDiffBoolArray

func (c *JSONCfg) MustGetDiffBoolArray(key ...any) ([]bool, error)

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

func (*JSONCfg) MustGetDiffBoolMap

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

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

func (*JSONCfg) MustGetDiffFloat32

func (c *JSONCfg) MustGetDiffFloat32(key ...any) (float32, error)

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

func (*JSONCfg) MustGetDiffFloat32Array

func (c *JSONCfg) MustGetDiffFloat32Array(key ...any) ([]float32, error)

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

func (*JSONCfg) MustGetDiffFloat32Map

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

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

func (*JSONCfg) MustGetDiffFloat64

func (c *JSONCfg) MustGetDiffFloat64(key ...any) (float64, error)

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

func (*JSONCfg) MustGetDiffFloat64Array

func (c *JSONCfg) MustGetDiffFloat64Array(key ...any) ([]float64, error)

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

func (*JSONCfg) MustGetDiffFloat64Map

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

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

func (*JSONCfg) MustGetDiffInt

func (c *JSONCfg) MustGetDiffInt(key ...any) (int, error)

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

func (*JSONCfg) MustGetDiffInt16

func (c *JSONCfg) MustGetDiffInt16(key ...any) (int16, error)

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

func (*JSONCfg) MustGetDiffInt16Array

func (c *JSONCfg) MustGetDiffInt16Array(key ...any) ([]int16, error)

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

func (*JSONCfg) MustGetDiffInt16Map

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

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

func (*JSONCfg) MustGetDiffInt32

func (c *JSONCfg) MustGetDiffInt32(key ...any) (int32, error)

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

func (*JSONCfg) MustGetDiffInt32Array

func (c *JSONCfg) MustGetDiffInt32Array(key ...any) ([]int32, error)

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

func (*JSONCfg) MustGetDiffInt32Map

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

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

func (*JSONCfg) MustGetDiffInt64

func (c *JSONCfg) MustGetDiffInt64(key ...any) (int64, error)

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

func (*JSONCfg) MustGetDiffInt64Array

func (c *JSONCfg) MustGetDiffInt64Array(key ...any) ([]int64, error)

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

func (*JSONCfg) MustGetDiffInt64Map

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

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

func (*JSONCfg) MustGetDiffIntArray

func (c *JSONCfg) MustGetDiffIntArray(key ...any) ([]int, error)

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

func (*JSONCfg) MustGetDiffIntMap

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

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

func (*JSONCfg) MustGetDiffMap

func (c *JSONCfg) MustGetDiffMap(
	key ...any,
) (map[string]any, error)

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

func (*JSONCfg) MustGetDiffString

func (c *JSONCfg) MustGetDiffString(key ...any) (string, error)

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

func (*JSONCfg) MustGetDiffStringArray

func (c *JSONCfg) MustGetDiffStringArray(key ...any) ([]string, error)

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

func (*JSONCfg) MustGetDiffStringMap

func (c *JSONCfg) MustGetDiffStringMap(
	key ...any,
) (map[string]string, error)

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

func (*JSONCfg) MustGetDiffUint

func (c *JSONCfg) MustGetDiffUint(key ...any) (uint, error)

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

func (*JSONCfg) MustGetDiffUint16

func (c *JSONCfg) MustGetDiffUint16(key ...any) (uint16, error)

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

func (*JSONCfg) MustGetDiffUint16Array

func (c *JSONCfg) MustGetDiffUint16Array(key ...any) ([]uint16, error)

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

func (*JSONCfg) MustGetDiffUint16Map

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

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

func (*JSONCfg) MustGetDiffUint32

func (c *JSONCfg) MustGetDiffUint32(key ...any) (uint32, error)

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

func (*JSONCfg) MustGetDiffUint32Array

func (c *JSONCfg) MustGetDiffUint32Array(key ...any) ([]uint32, error)

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

func (*JSONCfg) MustGetDiffUint32Map

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

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

func (*JSONCfg) MustGetDiffUint64

func (c *JSONCfg) MustGetDiffUint64(key ...any) (uint64, error)

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

func (*JSONCfg) MustGetDiffUint64Array

func (c *JSONCfg) MustGetDiffUint64Array(key ...any) ([]uint64, error)

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

func (*JSONCfg) MustGetDiffUint64Map

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

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

func (*JSONCfg) MustGetDiffUintArray

func (c *JSONCfg) MustGetDiffUintArray(key ...any) ([]uint, error)

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

func (*JSONCfg) MustGetDiffUintMap

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

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

func (*JSONCfg) MustGetFloat32

func (c *JSONCfg) MustGetFloat32(key ...any) (float32, error)

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

func (*JSONCfg) MustGetFloat32Array

func (c *JSONCfg) MustGetFloat32Array(key ...any) ([]float32, error)

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

func (*JSONCfg) MustGetFloat32Map

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

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

func (*JSONCfg) MustGetFloat64

func (c *JSONCfg) MustGetFloat64(key ...any) (float64, error)

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

func (*JSONCfg) MustGetFloat64Array

func (c *JSONCfg) MustGetFloat64Array(key ...any) ([]float64, error)

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

func (*JSONCfg) MustGetFloat64Map

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

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

func (*JSONCfg) MustGetInt

func (c *JSONCfg) MustGetInt(key ...any) (int, error)

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

func (*JSONCfg) MustGetInt16

func (c *JSONCfg) MustGetInt16(key ...any) (int16, error)

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

func (*JSONCfg) MustGetInt16Array

func (c *JSONCfg) MustGetInt16Array(key ...any) ([]int16, error)

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

func (*JSONCfg) MustGetInt16Map

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

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

func (*JSONCfg) MustGetInt32

func (c *JSONCfg) MustGetInt32(key ...any) (int32, error)

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

func (*JSONCfg) MustGetInt32Array

func (c *JSONCfg) MustGetInt32Array(key ...any) ([]int32, error)

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

func (*JSONCfg) MustGetInt32Map

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

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

func (*JSONCfg) MustGetInt64

func (c *JSONCfg) MustGetInt64(key ...any) (int64, error)

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

func (*JSONCfg) MustGetInt64Array

func (c *JSONCfg) MustGetInt64Array(key ...any) ([]int64, error)

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

func (*JSONCfg) MustGetInt64Map

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

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

func (*JSONCfg) MustGetIntArray

func (c *JSONCfg) MustGetIntArray(key ...any) ([]int, error)

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

func (*JSONCfg) MustGetIntMap

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

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

func (*JSONCfg) MustGetKeys

func (c *JSONCfg) MustGetKeys(keys ...any) ([]string, error)

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

func (*JSONCfg) MustGetMap

func (c *JSONCfg) MustGetMap(
	key ...any,
) (map[string]any, error)

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

func (*JSONCfg) MustGetString

func (c *JSONCfg) MustGetString(key ...any) (string, error)

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

func (*JSONCfg) MustGetStringArray

func (c *JSONCfg) MustGetStringArray(key ...any) ([]string, error)

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

func (*JSONCfg) MustGetStringMap

func (c *JSONCfg) MustGetStringMap(
	key ...any,
) (map[string]string, error)

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

func (*JSONCfg) MustGetUint

func (c *JSONCfg) MustGetUint(key ...any) (uint, error)

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

func (*JSONCfg) MustGetUint16

func (c *JSONCfg) MustGetUint16(key ...any) (uint16, error)

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

func (*JSONCfg) MustGetUint16Array

func (c *JSONCfg) MustGetUint16Array(key ...any) ([]uint16, error)

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

func (*JSONCfg) MustGetUint16Map

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

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

func (*JSONCfg) MustGetUint32

func (c *JSONCfg) MustGetUint32(key ...any) (uint32, error)

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

func (*JSONCfg) MustGetUint32Array

func (c *JSONCfg) MustGetUint32Array(key ...any) ([]uint32, error)

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

func (*JSONCfg) MustGetUint32Map

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

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

func (*JSONCfg) MustGetUint64

func (c *JSONCfg) MustGetUint64(key ...any) (uint64, error)

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

func (*JSONCfg) MustGetUint64Array

func (c *JSONCfg) MustGetUint64Array(key ...any) ([]uint64, error)

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

func (*JSONCfg) MustGetUint64Map

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

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

func (*JSONCfg) MustGetUintArray

func (c *JSONCfg) MustGetUintArray(key ...any) ([]uint, error)

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

func (*JSONCfg) MustGetUintMap

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

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

func (*JSONCfg) Reset

func (c *JSONCfg) Reset() error

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

func (*JSONCfg) Save

func (c *JSONCfg) Save() error

Save will save any unsaved changes to disk.

func (*JSONCfg) SaveDefault

func (c *JSONCfg) SaveDefault() error

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

func (*JSONCfg) SaveDiff

func (c *JSONCfg) SaveDiff() error

SaveDiff will save only the changes from default to disk.

func (*JSONCfg) Set

func (c *JSONCfg) Set(value any, keys ...any) error

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

func (*JSONCfg) SetDefault

func (c *JSONCfg) SetDefault(value any, keys ...any) 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

func (c *JSONCfg) String() string

String will return a string representation of the JSONCfg.

Directories

Path Synopsis
tools

Jump to

Keyboard shortcuts

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