Documentation ¶
Index ¶
- func IsUnsupportedExtensionErr(err error) bool
- func LoadConf[T any](path string, marshaler Marshaler) (T, error)
- func LoadConfContext[T any](ctx context.Context) (T, error)
- func SaveConf[T any](path string, marshaler Marshaler, v T) (T, error)
- func SaveConfContext(ctx context.Context) error
- type Gophig
- type JSONMarshaler
- type Marshaler
- type RawContext
- type TOMLMarshaler
- type UnsupportedExtensionError
- type YAMLMarshaler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsUnsupportedExtensionErr ¶
IsUnsupportedExtensionErr returns true if the error is an UnsupportedExtensionError.
func LoadConfContext ¶
LoadConfContext loads the configuration file into the given type.
Types ¶
type Gophig ¶
type Gophig[T any] struct { // contains filtered or unexported fields }
Gophig is a struct that contains the name, extension, and permission of a configuration file.
func NewGophig ¶
NewGophig returns a new Gophig struct.
func (*Gophig[T]) LoadConf ¶
LoadConf loads the configuration file into the given interface.
type JSONMarshaler ¶
type JSONMarshaler struct {
Indent bool
}
JSONMarshaler is a Marshaler that uses the goccy/go-json package.
func (JSONMarshaler) Marshal ¶
func (m JSONMarshaler) Marshal(v interface{}) ([]byte, error)
Marshal ...
func (JSONMarshaler) Unmarshal ¶
func (JSONMarshaler) Unmarshal(data []byte, v interface{}) error
Unmarshal ...
type Marshaler ¶
type Marshaler interface { Marshal(v interface{}) ([]byte, error) Unmarshal(data []byte, v interface{}) error }
Marshaler is an interface that can marshal and unmarshal data.
type RawContext ¶
func (*RawContext) Value ¶
func (c *RawContext) Value(key any) any
type TOMLMarshaler ¶
type TOMLMarshaler struct{}
TOMLMarshaler is a Marshaler that uses the pelletier/go-toml package.
func (TOMLMarshaler) Marshal ¶
func (TOMLMarshaler) Marshal(v interface{}) ([]byte, error)
Marshal ...
func (TOMLMarshaler) Unmarshal ¶
func (TOMLMarshaler) Unmarshal(data []byte, v interface{}) error
Unmarshal ...
type UnsupportedExtensionError ¶
type UnsupportedExtensionError struct {
// contains filtered or unexported fields
}
UnsupportedExtensionError is an error that is returned when a file extension is not supported.
func (UnsupportedExtensionError) Error ¶
func (e UnsupportedExtensionError) Error() string
Error ...
type YAMLMarshaler ¶
type YAMLMarshaler struct{}
YAMLMarshaler is a Marshaler that uses the go-yaml/yaml package.
func (YAMLMarshaler) Marshal ¶
func (YAMLMarshaler) Marshal(v interface{}) ([]byte, error)
Marshal ...
func (YAMLMarshaler) Unmarshal ¶
func (YAMLMarshaler) Unmarshal(data []byte, v interface{}) error
Unmarshal ...