Documentation
¶
Overview ¶
Package xconf provides a typed, declarative configuration DSL.
Schemas are built with fluent constructors (Int, String, Duration, Slice, Group, GroupAs, ...) and compose into a tree of Nodes. The same schema can be:
- serialized via Describe() and consumed by the xconfgen code generator to produce a typed *Config struct plus a Load() function with zero runtime reflection.
- bound at runtime via reflection (planned).
Validators live in github.com/gopherex/xconf/pkg/validate. Implementation lives in internal/core; this file is the public facade.
Index ¶
- Constants
- type Field
- func Bool(name string) *Field[bool]
- func Bytes(name string) *Field[[]byte]
- func Duration(name string) *Field[time.Duration]
- func Float32(name string) *Field[float32]
- func Float64(name string) *Field[float64]
- func Int(name string) *Field[int]
- func Int8(name string) *Field[int8]
- func Int16(name string) *Field[int16]
- func Int32(name string) *Field[int32]
- func Int64(name string) *Field[int64]
- func String(name string) *Field[string]
- func Time(name string) *Field[time.Time]
- func Uint(name string) *Field[uint]
- func Uint8(name string) *Field[uint8]
- func Uint16(name string) *Field[uint16]
- func Uint32(name string) *Field[uint32]
- func Uint64(name string) *Field[uint64]
- type FieldDesc
- type Kind
- type MapField
- type Node
- type Schema
- type SliceField
- type Validator
Constants ¶
View Source
const ( KindInvalid = core.KindInvalid KindInt = core.KindInt KindInt8 = core.KindInt8 KindInt16 = core.KindInt16 KindInt32 = core.KindInt32 KindInt64 = core.KindInt64 KindUint = core.KindUint KindUint8 = core.KindUint8 KindUint16 = core.KindUint16 KindUint32 = core.KindUint32 KindUint64 = core.KindUint64 KindFloat32 = core.KindFloat32 KindFloat64 = core.KindFloat64 KindString = core.KindString KindBytes = core.KindBytes KindBool = core.KindBool KindDuration = core.KindDuration KindTime = core.KindTime KindSlice = core.KindSlice KindMap = core.KindMap KindGroup = core.KindGroup )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MapField ¶
type MapField[K comparable, V any] = core.MapField[K, V]
func Map ¶
func Map[K comparable, V any](name string) *MapField[K, V]
type Schema ¶
func WithLoader ¶
type SliceField ¶
type SliceField[T any] = core.SliceField[T]
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
xconfgen
command
xconfgen renders a typed Go config struct + Load wrapper from an xconf schema variable.
|
xconfgen renders a typed Go config struct + Load wrapper from an xconf schema variable. |
|
example
|
|
|
app
Package app demonstrates an application schema that composes an external library schema (redislib.ConfigSchema).
|
Package app demonstrates an application schema that composes an external library schema (redislib.ConfigSchema). |
|
redislib
Package redislib is a hypothetical external library that exposes both a Config struct (consumed by users) and a ConfigSchema (consumed by xconfgen when an application embeds this library's configuration).
|
Package redislib is a hypothetical external library that exposes both a Config struct (consumed by users) and a ConfigSchema (consumed by xconfgen when an application embeds this library's configuration). |
|
internal
|
|
|
core
Package core holds the implementation of xconf.
|
Package core holds the implementation of xconf. |
|
pkg
|
|
|
codegen
Package codegen renders typed Go source for an xconf schema.
|
Package codegen renders typed Go source for an xconf schema. |
|
load
Package load is the runtime, reflection-based loader for xconf schemas.
|
Package load is the runtime, reflection-based loader for xconf schemas. |
|
structconf
Package structconf loads configuration into plain Go structs annotated with the classic `mapstructure` / `default` / `validate` tag triple, with no dependency on viper.
|
Package structconf loads configuration into plain Go structs annotated with the classic `mapstructure` / `default` / `validate` tag triple, with no dependency on viper. |
|
structtag
Package structtag provides a struct-first entry point to xconf.
|
Package structtag provides a struct-first entry point to xconf. |
|
validate
Package validate provides typed validators for xconf fields.
|
Package validate provides typed validators for xconf fields. |
Click to show internal directories.
Click to hide internal directories.