quick

package
v0.0.0-...-bed8137 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDuplicateKeys

func CheckDuplicateKeys(json string) error

CheckDuplicateKeys - checks for duplicate entries in a JSON file

func FormatJSONSyntaxError

func FormatJSONSyntaxError(data io.Reader, offset int64) (highlight string)

FormatJSONSyntaxError generates a pretty printed json syntax error since golang doesn't provide an easy way to report the location of the error

func GetVersion

func GetVersion(filename string) (version string, err error)

GetVersion - extracts the version information.

func Save

func Save(filename string, data interface{}) (err error)

Save - saves given configuration data into given file as JSON.

Types

type Config

type Config interface {
	String() string
	Version() string
	Save(string) error
	Load(string) error
	Data() interface{}
	Diff(Config) ([]structs.Field, error)
	DeepDiff(Config) ([]structs.Field, error)
}

Config - generic config interface functions

func Load

func Load(filename string, data interface{}) (qc Config, err error)

Load - loads json config from filename for the a given struct data

func New

func New(data interface{}) (Config, error)

New - instantiate a new config

type ConfigEncoding

type ConfigEncoding interface {
	Unmarshal([]byte, interface{}) error
	Marshal(interface{}) ([]byte, error)
}

ConfigEncoding is a generic interface which marshal/unmarshal configuration.

Jump to

Keyboard shortcuts

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