conffile

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 8 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. The last successful option determines the filename.

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 WithAppDir added in v0.11.2

func WithAppDir(unixDir, winDir, name string, force bool) Opt

WithAppDir determines the filename from the XDG or Windows specification. By default, this is based in $HOME/.config on Linux and %APPDATA% on Windows. If the file does not exist, this will set the filename only if "force" is true.

func WithDirName deprecated

func WithDirName(dir, name string) Opt

WithDirName determines the filename from a subdirectory in the user's HOME.

Deprecated: Replace with WithHomeDir

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 WithFullname

func WithFullname(fullname string) Opt

WithFullname specifies the filename. This will always set the filename even if the file does not exist.

func WithHomeDir added in v0.11.2

func WithHomeDir(dir, name string, force bool) Opt

WithHomeDir 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". If the file does not exist, this will set the filename only if "force" is true.

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