file

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

Backend that loads a configuration from a file. It supports json and yaml formats.

func NewBackend

func NewBackend(path string) *Backend

NewBackend creates a configuration loader that loads from a file. The content will get decoded based on the file extension. If optional parameter is set to true, calling Unmarshal won't return an error if the file doesn't exist.

func NewOptionalBackend added in v0.9.2

func NewOptionalBackend(path string) *Backend

NewOptionalBackend implementation is exactly the same as NewBackend except that if the file is not found, backend.ErrNotFound will be returned.

func (*Backend) Get

func (b *Backend) Get(ctx context.Context, key string) ([]byte, error)

Get is not implemented.

func (*Backend) Name

func (b *Backend) Name() string

Name returns the type of the file.

func (*Backend) Unmarshal added in v0.5.0

func (b *Backend) Unmarshal(ctx context.Context, to interface{}) error

Unmarshal takes a struct pointer and unmarshals the file into it, using either json or yaml based on the file extention.

Jump to

Keyboard shortcuts

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