file

package
v0.0.0-...-ecf7e73 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocalFolderLocator

func LocalFolderLocator(filename string) (name string, err error)

LocalFolderLocator locates files only in current folder

func NewFileConfiguration

func NewFileConfiguration(opts FullOptions) config.Configuration

NewFileConfiguration creates and returns new file-based configuration

func NewPlaceholdersReplacerReader

func NewPlaceholdersReplacerReader(originalReader func(string) ([]byte, error), props config.Configuration) func(string) ([]byte, error)

NewPlaceholdersReplacerReader return reader, that replaces placeholders

func NoopLocator

func NoopLocator(name string) (string, error)

NoopLocator is locator that does nothing, just returns provided string as response with nil error

Types

type FullOptions

type FullOptions struct {
	Options

	// Reader, used to read byte slice (file contents) into
	// intermediate key-value map
	ByteToMapReader func([]byte) (map[string]interface{}, error)

	// Mapper used to write final configuration values
	ReflectionMapper func(source interface{}, target interface{}) error
}

FullOptions holds full information, required to read a file

type Locator

type Locator func(string) (string, error)

Locator is function, able to found file in different locations

func NewCommonLocationsLocator

func NewCommonLocationsLocator(currentFolder, homeFolder, etc bool, subfolder string) Locator

NewCommonLocationsLocator return a locator, that will search for file in current folder, home folder and /etc/. Subfolder may be configured

type Options

type Options struct {
	// Configuration file name
	Filename string

	// Locator, used to find file
	Locator Locator

	// Reader, used to read file contents
	Reader Reader
}

Options holds minimal information, required to read a file

func (Options) WithDefaults

func (o Options) WithDefaults() Options

WithDefaults returns copy of options with default values set instead missing ones

type Reader

type Reader func(string) ([]byte, error)

Reader can read resolved file contents

func NewStringReader

func NewStringReader(data string) Reader

NewStringReader returns FileReader, that reads data from provided string. This is useful in unit tests

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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