pathed

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2018 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttributeError

func AttributeError(message, attr string) error

AttributeError is for when there is an error in using a required attribute.

func EmptyAttributeError

func EmptyAttributeError(attr string) error

EmptyAttributeError is for when a required attribute is empty.

func UnsupportedFormatError

func UnsupportedFormatError(format string) error

UnsupportedFormatError is for when asked to parse a format-type that's not supported.

Types

type Config

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

Config contains the given "path", "extn" and "body" of a config, as well as the parsed config --> KV map.

func New

func New() *Config

New object

func (*Config) Body

func (s *Config) Body() string

Body returns s.path as a key, for use by the configs package.

func (*Config) ConfigFormat

func (s *Config) ConfigFormat() (ConfigFormats, error)

ConfigFormat returns an enum representing the format of s.body.

func (*Config) Key

func (s *Config) Key() string

Key returns s.path as a key, for use by the configs package.

func (*Config) ParseError

func (s *Config) ParseError(err error) error

ParseError is for when failing to parse a config.

func (*Config) SetBody

func (s *Config) SetBody(body string) *Config

SetBody adds Body string to the Config struct.

func (*Config) SetPath

func (s *Config) SetPath(path string) *Config

SetPath adds Path string to the Config struct.

func (*Config) ToBodyMap

func (s *Config) ToBodyMap() (common.BodyMap, error)

ToBodyMap returns the parsed map, for use by the configs package.

func (*Config) Unmarshal

func (s *Config) Unmarshal() error

Unmarshal decodes/parses the given s.body string into the s.parsed field. TODO: Use Viper, instead:

type ConfigFormats

type ConfigFormats int

ConfigFormats defines the type for the *Format enum.

const (
	// UnknownFormat is when the config file format isn't recognised.
	UnknownFormat ConfigFormats = iota
	// EnvFormat is when the config file format is ".env".
	EnvFormat
	// TOMLFormat is when the config file format is TOML.
	TOMLFormat
	// YAMLFormat is when the config file format is YAML.
	YAMLFormat
	// JSONFormat is when the config file format is JSON.
	JSONFormat
)

Jump to

Keyboard shortcuts

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