Documentation
¶
Index ¶
- Constants
- Variables
- func Async(config interface{}, fn func() (string, error)) error
- func IsNotFoundErr(err error) bool
- func Load(config any, options ...*LoadOptions) error
- func LoadFromService(config interface{}, fn func() (string, error)) error
- func Parse(data []byte, config interface{}, opts ...*ParseOptions) error
- type LoadOptions
- type ParseOptions
Constants ¶
View Source
const DefaultFileType = "YAML"
DefaultFileType is the default file type.
Variables ¶
View Source
var Version = "1.4.0"
Version is the version of this package.
Functions ¶
func IsNotFoundErr ¶ added in v1.2.9
IsNotFoundErr returns true if the error is a not found error.
func Load ¶
func Load(config any, options ...*LoadOptions) error
Load loads the config from the given file path. If the file path is empty, it will load the config from the default file path. Default file path is
custom file path > ${PWD}/.{APP_NAME}.{NAME}.yml /etc/{APP_NAME}/{NAME}.yml (user is root) | $HOME/.config/{APP_NAME}/{NAME}.yml. > ${PWD}/.{APP_NAME}.yml > /etc/{APP_NAME}/config.yml (user is root) | $HOME/.config/{APP_NAME}/config.yml. > ${PWD}/.config.yml
func LoadFromService ¶ added in v1.0.10
LoadFromService loads the config from the given service.
func Parse ¶ added in v1.0.10
func Parse(data []byte, config interface{}, opts ...*ParseOptions) error
Parse parses the config from the given raw config.
Types ¶
type LoadOptions ¶
type LoadOptions struct { // FilePath is the config file path. // If the file path is empty, it will load the config from the default file path. // Default file path is ${PWD}/.config.yml. // If the file path is a URL, it will fetch the config file from the URL. // The URL must be started with http:// or https://. FilePath string // options: YAML | JSON | TOML | INI | HOST, default: YAML Type string // Unique AppName for the config file, default: "" AppName string // Config name, default: config.yml, and type is YAML Name string }
LoadOptions is the options for Load
type ParseOptions ¶ added in v1.2.11
type ParseOptions struct { // The type of the config file, default is "YAML". // options: YAML | JSON | TOML | INI | HOST Type string }
ParseOptions is the options for Parse.
Click to show internal directories.
Click to hide internal directories.