file

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 2 Imported by: 0

README

file

A library for loading configuration files into config.

GoDoc

Documentation

Overview

Package file provides a file loader for config.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

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

Loader provides reads configuration from the local filesystem.

func New

func New(filename string, options ...Option) *Loader

New creates a loader with the specified path.

func (*Loader) Load

func (l *Loader) Load() ([]byte, error)

Load returns the current content of the file. The file is expected to exist and be readable, else an error is returned.

func (*Loader) NewWatcher

func (l *Loader) NewWatcher(done <-chan struct{}) <-chan error

NewWatcher returns a channel of update events the loader. The watcher must be enabled using the WithWatch construction option. The watcher will send nil events when the loader has changed. If a terminal error occurs it is sent to the update channel which is then closed. The watcher will exit when the done is closed or a terminal error occurs.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is a construction option for a Blob.

type WatcherOption

type WatcherOption struct {
}

WatcherOption enables a watcher on the file.

func WithWatcher

func WithWatcher() WatcherOption

WithWatcher is an Option that enables watching of the file. This is an option to ensure it can only set at construction time, so the watcher is a singleton and is created before the file is initially loaded. Note that watched files must be closed to terminate the watch.

Jump to

Keyboard shortcuts

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