Documentation ¶
Index ¶
- Variables
- type Gonfig
- type OptionFunc
- func OptionAppendFlagConfig(fc flagConfig) OptionFunc
- func OptionDisableDefaultFlagConfiguration(v bool) OptionFunc
- func OptionSetConfigFilePathVariable(path string) OptionFunc
- func OptionSetFileSystem(fs afero.Fs) OptionFunc
- func OptionSetFlagConfiguration(fc flagConfiguration) OptionFunc
- func OptionSetOsArgs(osArgs []string) OptionFunc
- type Repository
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyConfigFilePath is an error indicating that a file path is empty. ErrEmptyConfigFilePath = errors.New("filepath is empty") // ErrInvalidConfigModel is an error indicating that a configuration model is invalid. ErrInvalidConfigModel = errors.New("model is empty or no valid struct") // ErrConfigFileExist is an error indicating that the configuration file exists and an empty skeleton can not be generated ErrConfigFileExist = errors.New("unable to generate skeleton. file already exists") )
Functions ¶
This section is empty.
Types ¶
type Gonfig ¶ added in v0.3.0
type Gonfig interface { // Load loads configuration data from the file at the file path into the given model. Load(model interface{}) error // WriteSkeleton writes a JSON skeleton of the model to the file path. WriteSkeleton(model interface{}) error // IsEmpty checks if the config file is empty. Returns `true` if the file does not exist or is empty. IsEmpty(model interface{}) (bool, error) }
Gonfig interface contains all the functions that are available to public use.
func New ¶
func New(options ...OptionFunc) (Gonfig, error)
New creates a new Repository with the given options. It applies the flag configuration, generates a default file path if not disabled, and returns the Repository
type OptionFunc ¶
type OptionFunc func(r *Repository)
OptionFunc is a function that takes a Repository pointer and modifies it based on the function's implementation.
func OptionAppendFlagConfig ¶
func OptionAppendFlagConfig(fc flagConfig) OptionFunc
OptionAppendFlagConfig appends the given `flagConfig` to the flag configuration.
func OptionDisableDefaultFlagConfiguration ¶
func OptionDisableDefaultFlagConfiguration(v bool) OptionFunc
OptionDisableDefaultFlagConfiguration disables the default flag configuration.
func OptionSetConfigFilePathVariable ¶
func OptionSetConfigFilePathVariable(path string) OptionFunc
OptionSetConfigFilePathVariable sets the file path and disables default path generation.
func OptionSetFileSystem ¶
func OptionSetFileSystem(fs afero.Fs) OptionFunc
OptionSetFileSystem sets the file system.
func OptionSetFlagConfiguration ¶
func OptionSetFlagConfiguration(fc flagConfiguration) OptionFunc
OptionSetFlagConfiguration sets the flag configuration to the given `flagConfiguration`.
func OptionSetOsArgs ¶
func OptionSetOsArgs(osArgs []string) OptionFunc
OptionSetOsArgs sets the os arguments.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository struct is the initialized gonfig.
func (*Repository) IsEmpty ¶ added in v0.2.0
func (r *Repository) IsEmpty(model interface{}) (bool, error)
IsEmpty checks if the config file is empty. Returns `true` if the file does not exist or is empty.
func (*Repository) Load ¶
func (r *Repository) Load(model interface{}) error
Load loads configuration data from the file at the file path into the given model.
func (*Repository) WriteSkeleton ¶
func (r *Repository) WriteSkeleton(model interface{}) error
WriteSkeleton writes a JSON skeleton of the model to the file path.