config

package
v0.0.0-...-b2761b6 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2014 License: GPL-3.0, GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config has helpers to parse and use JSON based configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFile

func LoadFile(p, baseDir string) ([]byte, error)

LoadFile reads a file possibly relative to a base dir.

func ReadConfig

func ReadConfig(r io.Reader, destConfig interface{}) error

ReadConfig reads a JSON configuration into destConfig which should be a pointer to a structure, it does some more configuration specific error checking than plain JSON decoding and mentions fields in errors . Configuration fields are expected to start with lower case in the JSON object.

func ReadFiles

func ReadFiles(destConfig interface{}, cfgFpaths ...string) error

ReadFiles reads configuration from a set of files. Uses ReadConfig internally.

Types

type ConfigHostPort

type ConfigHostPort string

ConfigHostPort can hold a host:port string in a configuration struct.

func (ConfigHostPort) HostPort

func (chp ConfigHostPort) HostPort() string

HostPort returns the host:port string held in chp.

func (*ConfigHostPort) UnmarshalJSON

func (chp *ConfigHostPort) UnmarshalJSON(b []byte) error

type ConfigQueueSize

type ConfigQueueSize uint

ConfigQueueSize can hold a queue size in a configuration struct.

func (ConfigQueueSize) QueueSize

func (cqs ConfigQueueSize) QueueSize() uint

QueueSize returns the queue size held in cqs.

func (*ConfigQueueSize) UnmarshalJSON

func (cqs *ConfigQueueSize) UnmarshalJSON(b []byte) error

type ConfigTimeDuration

type ConfigTimeDuration struct {
	time.Duration
}

ConfigTimeDuration can hold a time.Duration in a configuration struct, that is parsed from a string as supported by time.ParseDuration.

func (ConfigTimeDuration) TimeDuration

func (ctd ConfigTimeDuration) TimeDuration() time.Duration

TimeDuration returns the time.Duration held in ctd.

func (*ConfigTimeDuration) UnmarshalJSON

func (ctd *ConfigTimeDuration) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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