conffile

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package conffile wraps the read and write of configuration files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

func New

func New(opts ...Opt) *File

New returns a new File

func (*File) Name

func (f *File) Name() string

func (*File) Open

func (f *File) Open() (io.ReadCloser, error)

func (*File) Write

func (f *File) Write(rdr io.Reader) error

type Opt

type Opt func(*File)

func WithDirName

func WithDirName(dir, name string) Opt

WithDirName determines the filename from a subdirectory in the user's HOME e.g. dir=".app", name="config.json", sets the fullname to "$HOME/.app/config.json"

func WithEnvDir added in v0.4.4

func WithEnvDir(envVar, name string) Opt

WithEnvDir sets the fullname to the environment value + filename if the environment variable is defined

func WithEnvFile added in v0.4.4

func WithEnvFile(envVar string) Opt

WithEnvFile sets the fullname to the environment value if defined

func WithFS

func WithFS(fs rwfs.RWFS) Opt

WithFS overrides the default OS filesystem

func WithFullname

func WithFullname(fullname string) Opt

WithFullname specifies the filename

func WithPerms

func WithPerms(perms int) Opt

WithPerms specifies the permissions to create a file with (default 0600)

Jump to

Keyboard shortcuts

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