conf

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FillDefault

func FillDefault(v any) error

FillDefault fills the default values for the given v, and the premise is that the value of v must be guaranteed to be empty.

func Load

func Load(file string, v any, opts ...Option) error

Load loads config into v from file, .json, .json5, .toml, .yaml and .yml are acceptable.

func LoadConfig deprecated

func LoadConfig(file string, v any, opts ...Option) error

LoadConfig loads config into v from file, .json, .json5, .toml, .yaml and .yml are acceptable.

Deprecated: use Load instead.

func LoadConfigFromJsonBytes deprecated

func LoadConfigFromJsonBytes(content []byte, v any) error

LoadConfigFromJsonBytes loads config into v from content json bytes.

Deprecated: use LoadFromJsonBytes instead.

func LoadConfigFromYamlBytes deprecated

func LoadConfigFromYamlBytes(content []byte, v any) error

LoadConfigFromYamlBytes loads config into v from content yaml bytes.

Deprecated: use LoadFromYamlBytes instead.

func LoadFromJson5Bytes

func LoadFromJson5Bytes(content []byte, v any) error

LoadFromJson5Bytes loads config into v from content json5 bytes.

func LoadFromJsonBytes

func LoadFromJsonBytes(content []byte, v any) error

LoadFromJsonBytes loads config into v from content json bytes.

func LoadFromTomlBytes

func LoadFromTomlBytes(content []byte, v any) error

LoadFromTomlBytes loads config into v from content toml bytes.

func LoadFromYamlBytes

func LoadFromYamlBytes(content []byte, v any) error

LoadFromYamlBytes loads config into v from content yaml bytes.

func MustLoad

func MustLoad(path string, v any, opts ...Option)

MustLoad loads config into v from path, exits on error.

Types

type Option

type Option func(opt *options)

Option defines the method to customize the config options.

func UseEnv

func UseEnv() Option

UseEnv customizes the config to use environment variables.

type Properties

type Properties interface {
	GetString(key string) string
	SetString(key, value string)
	GetInt(key string) int
	SetInt(key string, value int)
	ToString() string
}

Properties interface provides the means to access configuration.

func LoadProperties

func LoadProperties(filename string, opts ...Option) (Properties, error)

LoadProperties loads the properties into a properties configuration instance. Returns an error that indicates if there was a problem loading the configuration.

func NewProperties

func NewProperties() Properties

NewProperties builds a new properties configuration structure.

type PropertyError

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

PropertyError represents a configuration error message.

func (*PropertyError) Error

func (configError *PropertyError) Error() string

Error returns the error message.

Jump to

Keyboard shortcuts

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