Documentation ¶
Overview ¶
Package conf provides a way to get configuration from multiple sources, using a single struct to define the fields.
Index ¶
- Constants
- Variables
- func BaseName(n string) fileOptFn
- func ConfigPaths(appName string) fileOptErrFn
- func FilesEnv(filenames ...string) environSource
- func Flags(dst any, opts ...flagOpt) *flag.FlagSet
- func LoadEnv(dst any, opts ...envOpt) error
- func LoadFile(dst any, opts ...fileOpt) error
- func Must(err error)
- func PFlags(dst any, opts ...flagOpt) *pflag.FlagSet
- func Paths(paths ...string) fileOptFn
- func SaveFile(obj any, filename string, format format) error
- type Documentation
- type Field
- type URL
Constants ¶
View Source
const Required required = true
Variables ¶
View Source
var ( JSON format = format{[]string{".json"}, json.Marshal, json.Unmarshal} XML format = format{[]string{".xml"}, xml.Marshal, xml.Unmarshal} TOML format = format{[]string{".toml"}, toml.Marshal, toml.Unmarshal} YAML format = format{[]string{".yaml", ".yml"}, yaml.Marshal, yaml.Unmarshal} )
View Source
var ColumnDefault = tableColumn{/* contains filtered or unexported fields */}
View Source
var ColumnEnv = tableColumn{/* contains filtered or unexported fields */}
View Source
var ColumnFlag = tableColumn{/* contains filtered or unexported fields */}
View Source
var ColumnFlagShort = tableColumn{/* contains filtered or unexported fields */}
View Source
var ColumnJSON = tableColumn{/* contains filtered or unexported fields */}
View Source
var ColumnName = tableColumn{/* contains filtered or unexported fields */}
View Source
var ColumnUsage = tableColumn{/* contains filtered or unexported fields */}
View Source
var DefaultTableColumns = []tableColumn{ ColumnName, ColumnDefault, ColumnUsage, }
View Source
var FileEnv = FilesEnv()
View Source
var OSEnv environSource = environSource(os.Environ)
Functions ¶
func ConfigPaths ¶
func ConfigPaths(appName string) fileOptErrFn
ConfigPaths causes a file read to pull from the OS-specific configuration directory.
Types ¶
type Documentation ¶
func Help ¶
func Help(dst any) *Documentation
func (*Documentation) Markdown ¶
func (d *Documentation) Markdown(columns ...tableColumn) string
func (*Documentation) String ¶
func (d *Documentation) String() string
func (*Documentation) WriteToTable ¶
func (d *Documentation) WriteToTable(table *tablewriter.Table, columns ...tableColumn)
Click to show internal directories.
Click to hide internal directories.