file

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 4 Imported by: 5

Documentation

Overview

Package file provides config file support for uconfig

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(path string, unmarshal Unmarshal, config Config) plugins.Plugin

New returns an EnvSet.

func NewReader

func NewReader(src io.Reader, unmarshal Unmarshal) plugins.Plugin

NewReader returns a uconfig plugin that unmarshals the content of the provided io.Reader into the config using the provided unmarshal function. The src will be closed if it is an io.Closer.

Types

type Config

type Config struct {
	// indicates if a file that does not exist should be ignored.
	Optional bool
}

Config describes the options required for a file.

type Files

type Files []struct {
	Path      string
	Unmarshal Unmarshal
	Optional  bool
}

Files represents a set of file paths and the appropriate unmarshal function for the given file.

func (Files) Plugins

func (f Files) Plugins() []plugins.Plugin

Plugins constructs a slice of Plugin from the Files list of paths and unmarshal functions.

type Unmarshal

type Unmarshal func(src []byte, v interface{}) error

Unmarshal is any function that maps the source bytes to the provided config.

Jump to

Keyboard shortcuts

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