config

package
v3.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config is an interface for dynamic configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(path string, options ...Option) error

Delete the value at a path

func Set

func Set(path string, val interface{}, options ...Option) error

Set the value at a path

Types

type Config

type Config interface {
	Get(path string, options ...Option) (Value, error)
	Set(path string, val interface{}, options ...Option) error
	Delete(path string, options ...Option) error
}

Config is an interface abstraction for dynamic configuration

var DefaultConfig Config

DefaultConfig implementation

type JSONValue

type JSONValue struct {
	*simple.Json
}

func NewJSONValue

func NewJSONValue(data []byte) *JSONValue

func (*JSONValue) Bool

func (j *JSONValue) Bool(def bool) bool

func (*JSONValue) Bytes

func (j *JSONValue) Bytes() []byte

func (*JSONValue) Duration

func (j *JSONValue) Duration(def time.Duration) time.Duration

func (*JSONValue) Exists

func (j *JSONValue) Exists() bool

func (*JSONValue) Float64

func (j *JSONValue) Float64(def float64) float64

func (*JSONValue) Int

func (j *JSONValue) Int(def int) int

func (*JSONValue) Scan

func (j *JSONValue) Scan(v interface{}) error

func (*JSONValue) String

func (j *JSONValue) String(def string) string

func (*JSONValue) StringMap

func (j *JSONValue) StringMap(def map[string]string) map[string]string

func (*JSONValue) StringSlice

func (j *JSONValue) StringSlice(def []string) []string

type JSONValues

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

func NewJSONValues

func NewJSONValues(data []byte) *JSONValues

func (*JSONValues) Bytes

func (j *JSONValues) Bytes() []byte

func (*JSONValues) Delete

func (j *JSONValues) Delete(path string, options ...Option)

func (*JSONValues) Get

func (j *JSONValues) Get(path string, options ...Option) Value

func (*JSONValues) Map

func (j *JSONValues) Map() map[string]interface{}

func (*JSONValues) Scan

func (j *JSONValues) Scan(v interface{}) error

func (*JSONValues) Set

func (j *JSONValues) Set(path string, val interface{}, options ...Option)

func (*JSONValues) String

func (j *JSONValues) String() string

type Option

type Option func(o *Options)

func Secret

func Secret(b bool) Option

type Options

type Options struct {
	Secret bool
}

type Secrets

type Secrets interface {
	Config
}

type Value

type Value interface {
	Exists() bool
	Bool(def bool) bool
	Int(def int) int
	String(def string) string
	Float64(def float64) float64
	Duration(def time.Duration) time.Duration
	StringSlice(def []string) []string
	StringMap(def map[string]string) map[string]string
	Scan(val interface{}) error
	Bytes() []byte
}

Value represents a value of any type

func Get

func Get(path string, options ...Option) (Value, error)

Get a value at the path

Directories

Path Synopsis
Package env provides config from environment variables
Package env provides config from environment variables

Jump to

Keyboard shortcuts

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