prefer

package module
v0.0.0-...-167af1f Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2018 License: MIT Imports: 10 Imported by: 1

README

prefer.go

Powerful configuration management in Go

Documentation

Overview

+build !windows

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StandardPaths

func StandardPaths() []string

StandardPaths provides base paths for searching for discoverying files

Types

type Configuration

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

Configuration represents a specific configuration loaded by Prefer

func Load

func Load(identifier string, options *interface{}, out interface{}) (*Configuration, error)

Load creates and loads a Configuration object

func (*Configuration) Identifier

func (configuration *Configuration) Identifier() string

Identifier returns the identifier for the loaded configuration

type FileLoader

type FileLoader struct{}

FileLoader reads bytes from regular files

func (FileLoader) Discover

func (loader FileLoader) Discover(identifier string) (string, error)

Discover attempts to match the given identifier to the closest file match

func (FileLoader) Load

func (loader FileLoader) Load(identifier string) ([]byte, string, error)

Load loads a specific file from the filesystem

type JSONSerializer

type JSONSerializer struct{}

JSONSerializer serializers to/from JSON format

func (JSONSerializer) Deserialize

func (serializer JSONSerializer) Deserialize(input []byte, obj interface{}) error

Deserialize receives []byte and fills obj with it's deserialized values

func (JSONSerializer) Serialize

func (serializer JSONSerializer) Serialize(input interface{}) ([]byte, error)

Serialize receives an object and returns a serialized version of it

type Loader

type Loader interface {
	Discover(identifier string) (string, error)
	Load(identifier string) ([]byte, string, error)
}

A Loader represents a specific way of loading bytes from a data source

func NewLoader

func NewLoader(identifier string) (Loader, error)

NewLoader creates a new Loader based on the given identifier

type Serializer

type Serializer interface {
	Serialize(interface{}) ([]byte, error)
	Deserialize([]byte, interface{}) error
}

Serializer provides an interface for packing and unpacking data

func SerializerFor

func SerializerFor(identifier string, content []byte) (serializer Serializer, err error)

SerializerFor gets a serializer matching the given identifier

type XMLSerializer

type XMLSerializer struct{}

XMLSerializer serializers to/from XML format

func (XMLSerializer) Deserialize

func (serializer XMLSerializer) Deserialize(input []byte, obj interface{}) error

Deserialize receives []byte and fills obj with it's deserialized values

func (XMLSerializer) Serialize

func (serializer XMLSerializer) Serialize(input interface{}) ([]byte, error)

Serialize receives an object and returns a serialized version of it

type YAMLSerializer

type YAMLSerializer struct{}

YAMLSerializer serializers to/from YAML format

func (YAMLSerializer) Deserialize

func (serializer YAMLSerializer) Deserialize(input []byte, obj interface{}) error

Deserialize receives []byte and fills obj with it's deserialized values

func (YAMLSerializer) Serialize

func (serializer YAMLSerializer) Serialize(input interface{}) ([]byte, error)

Serialize receives an object and returns a serialized version of it

Jump to

Keyboard shortcuts

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