fs

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package fs loads configuration from file system.

FS loads a file with the given path from the file system and returns a nested map[string]any that is parsed with the given unmarshal function.

The unmarshal function must be able to unmarshal the file content into a map[string]any. For example, with the default json.Unmarshal, the file is parsed as JSON.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

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

FS is a Provider that loads configuration from file system.

To create a new FS, call New.

func New

func New(fs fs.FS, path string, opts ...Option) FS

New creates a FS with the given fs.FS, path and Option(s).

func (FS) Load

func (f FS) Load() (map[string]any, error)

func (FS) String

func (f FS) String() string

type Option

type Option func(file *options)

Option configures the a FS with specific options.

func WithUnmarshal

func WithUnmarshal(unmarshal func([]byte, any) error) Option

WithUnmarshal provides the function used to parses the configuration file. The unmarshal function must be able to unmarshal the file content into a map[string]any.

The default function is json.Unmarshal.

Jump to

Keyboard shortcuts

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