configparser

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 9 Imported by: 8

Documentation

Index

Constants

View Source
const (
	DefaultConfigDelimiter      string = "."
	DefaultEnvironmentDelimiter string = "__"
	DefaultFilename             string = "config.json"
)

Variables

This section is empty.

Functions

func GetPaths

func GetPaths(applicationName string) ([]string, error)

GetPaths returns the different paths based on the operating system running this method.

func Parse

func Parse[C Parsable](opts ParserOptions) (c C, err error)

Parse attempts to parse the configuration in JSON format from paths from GetPaths afterwards, environment variables override the config values.

Types

type Parsable

type Parsable interface {
	// Validate should return when there's a validation error.
	Validate() (err error)
	// SetPath will be called with the config loaded path.
	SetPath(path string)
}

Parsable represents a config that can be validated and a path to be set.

type ParserOptions

type ParserOptions struct {
	EnvironmentReplacer  string
	EnvironmentDelimiter string
	ConfigDelimiter      string
	ApplicationName      string
	Filename             string
}

Jump to

Keyboard shortcuts

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