Documentation
¶
Overview ¶
Package file provides config file support for uconfig
Index ¶
- Variables
- func FileNames(ps []plugins.Plugin) []string
- func FilePaths(ps []plugins.Plugin) []string
- func New(path string, unmarshal Unmarshal, config Config) plugins.Plugin
- func NewMulti(path string, unmarshalOptions UnmarshalOptions, optional bool) plugins.Plugin
- func NewReader(src io.Reader, filepath string, unmarshal Unmarshal) plugins.Plugin
- type Config
- type Files
- type Path
- type Unmarshal
- type UnmarshalOptions
Constants ¶
This section is empty.
Variables ¶
var ErrFileExtNotSupported = errors.New("file extension not supported")
Functions ¶
func FileNames ¶ added in v0.13.0
FileNames returns the display names of file paths from a list of plugins, filtering out non-file plugins. These are the names as provided by the user, not resolved absolute paths.
func FilePaths ¶ added in v0.12.0
FilePaths returns the resolved filesystem paths from a list of plugins, filtering out non-file plugins. Paths are available after Walk has been called.
func NewMulti ¶ added in v0.8.0
func NewMulti(path string, unmarshalOptions UnmarshalOptions, optional bool) plugins.Plugin
NewMulti returns a multi unmarshal plugin that can decode the file from path using various Unmarshal functions provided in unmarshal map. This is usually used as a second stage to load configurations based on a flag or configuration value.
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 ¶
Files represents a set of file paths and the appropriate unmarshal function for the given file.
type Path ¶ added in v0.13.0
Path pairs a display name with a lazy path resolver. The Name is shown in usage output; Resolve is called during Walk to obtain the actual filesystem path.
func Relative ¶ added in v0.13.0
Relative returns a Path that resolves a relative path against the working directory at the time of the call.
func Workspace ¶ added in v0.13.0
Workspace returns a Path that walks up the directory tree looking for a file at the given relative path (e.g. ".myapp/config"). Returns the absolute path of the first match, or empty string if not found.
The search always starts from the current working directory.
This implements the common ancestor-directory search pattern used by tools like git (.git), eslint (.eslintrc), and similar.