envfile

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: BSD-3-Clause Imports: 6 Imported by: 1

Documentation

Overview

Package envfile provides tools to read and load environment variables from files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(filename string) error

Load reads from filename and sets the environment variables using env.Load.

func LoadFS

func LoadFS(fsys fs.FS, filename string) error

LoadFS reads from filename and sets the environment variables using env.Load.

func Overload

func Overload(filename string) error

Overload reads from filename and sets and overwrites the environment variables using env.Overload.

func OverloadFS

func OverloadFS(fsys fs.FS, filename string) error

OverloadFS reads from filename and sets and overwrites the environment variables using env.Overload.

func Write

func Write(filename string, v any) error

Types

type Encoder

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

func Create

func Create(filename string) (*Encoder, error)

func NewEncoder

func NewEncoder(f *os.File) *Encoder

func (*Encoder) Close

func (fe *Encoder) Close() error

Close closes the underlying os.File.

type Reader

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

func NewReader

func NewReader(f fs.File) *Reader

NewReader returns a Reader which looks up environment variables from the provided fs.File.

dec := env.NewDecoder(envfile.NewReader(file))

func Open

func Open(filename string) (*Reader, error)

Open opens filename for reading using os.Open and returns a new *Reader. It is the caller's responsibility to close the Reader when finished. If there is an error, it will be of type *os.PathError.

func OpenFS

func OpenFS(fsys fs.FS, filename string) (*Reader, error)

OpenFS opens filename for reading from fsys and returns a new *Reader. It is the caller's responsibility to close the Reader when finished. If there is an error, it will be of type *os.PathError.

func (*Reader) Close

func (f *Reader) Close() error

Close closes the underlying fs.File.

Jump to

Keyboard shortcuts

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