sourcefile

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package sourcefile sources configuration from file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(path string, opts ...Option) config.SourceCreationFunc

New returns a new file source.

Types

type File

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

File implements config.Source to fetch values from a file.

func (*File) Name

func (f *File) Name() string

Name implements config.Source interface.

func (*File) Unmarshal

func (f *File) Unmarshal(to interface{}) error

Unmarshal tries to unmarshal file to the provided interface. It returns a trivial error if load strictness is false, or the true error otherwise.

type Option

type Option func(f *File)

Option defines the function signature to apply options.

func FailOnUnknownFields

func FailOnUnknownFields() Option

FailOnUnknownFields tells the file decoder to fail if a key exists in the file but not in the destination.

func MayNotExist

func MayNotExist() Option

MayNotExist tells the file.Unmarshal function to return an error that implements IsTrivial when file does not exists.

Jump to

Keyboard shortcuts

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