Documentation
¶
Index ¶
- Constants
- Variables
- func GetConventionForSourceType(sourceType SourceType) string
- func RegisterSource(typ string, builder SourceBuilder)
- func SetConventionForSourceType(sourceType SourceType, convention string)
- type CamelCaseNormalizer
- type EnvSource
- type KeyNormalizer
- type MapSource
- type Options
- type PrefixedSource
- type Reader
- type SnakeCaseNormalizer
- type Source
- type SourceBuilder
- type SourceOptions
- type SourceType
- type UnknownConventionError
- type UpperSnakeCaseNormalizer
Constants ¶
View Source
const ( SnakeCaseConvention = "snake" CamelCaseConvention = "camel" UpperSnakeCaseConvention = "upper_snake" )
Variables ¶
View Source
var (
InvalidBooleanError = errors.New("invalid boolean value")
)
Functions ¶
func GetConventionForSourceType ¶
func GetConventionForSourceType(sourceType SourceType) string
func RegisterSource ¶
func RegisterSource(typ string, builder SourceBuilder)
func SetConventionForSourceType ¶
func SetConventionForSourceType(sourceType SourceType, convention string)
Types ¶
type CamelCaseNormalizer ¶
type CamelCaseNormalizer struct{}
func (*CamelCaseNormalizer) Normalize ¶
func (n *CamelCaseNormalizer) Normalize(key string) string
type EnvSource ¶
type EnvSource struct {
// contains filtered or unexported fields
}
func NewEnvSource ¶
type KeyNormalizer ¶
func GetNormalizer ¶
func GetNormalizer(convention string) KeyNormalizer
func NormalizerForSourceType ¶
func NormalizerForSourceType(convention string, sourceType SourceType) (KeyNormalizer, error)
type MapSource ¶
type MapSource struct {
// contains filtered or unexported fields
}
func NewJSONSource ¶
func NewYAMLSource ¶
func (*MapSource) Type ¶
func (s *MapSource) Type() SourceType
type Options ¶
type Options struct { SourceOptions SourceOptions SourceType SourceType }
type PrefixedSource ¶
type PrefixedSource struct {
// contains filtered or unexported fields
}
func (*PrefixedSource) Read ¶
func (s *PrefixedSource) Read(target interface{}) error
func (*PrefixedSource) ReadKey ¶
func (s *PrefixedSource) ReadKey(key string, target interface{}) error
func (*PrefixedSource) Type ¶
func (s *PrefixedSource) Type() SourceType
type SnakeCaseNormalizer ¶
type SnakeCaseNormalizer struct{}
func (*SnakeCaseNormalizer) Normalize ¶
func (n *SnakeCaseNormalizer) Normalize(key string) string
type Source ¶
type Source interface { Type() SourceType Read(target interface{}) error ReadKey(key string, target interface{}) error }
func BuildEnvSource ¶
func BuildEnvSource(opts SourceOptions) (Source, error)
BuildEnvSource This function only fails if the .env file path is explicitly provided and doesn't exist
func BuildJSONSource ¶
func BuildJSONSource(opts SourceOptions) (Source, error)
func BuildYAMLSource ¶
func BuildYAMLSource(opts SourceOptions) (Source, error)
func PrefixSourceWith ¶
type SourceBuilder ¶
type SourceBuilder = func(opts SourceOptions) (Source, error)
type SourceOptions ¶
type SourceType ¶
type SourceType = string
const ( YAMLSourceType SourceType = "yaml" JSONSourceType = "json" )
const EnvSourceType SourceType = "env"
type UnknownConventionError ¶
type UnknownConventionError struct {
Convention string
}
func (UnknownConventionError) Error ¶
func (u UnknownConventionError) Error() string
type UpperSnakeCaseNormalizer ¶
type UpperSnakeCaseNormalizer struct{}
func (*UpperSnakeCaseNormalizer) Normalize ¶
func (n *UpperSnakeCaseNormalizer) Normalize(key string) string
Normalize todo: Optimize this process
Click to show internal directories.
Click to hide internal directories.