func NewConfig() (*Config, error) {

	myFuncName := caller.GetFuncName()

	var config Config

	// Bundle the returned `*.arg.Parser` for later use from `main()` so that
	// we can explicitly display usage or help details should the
	// user-provided settings fail validation.
	log.Debugf("%s: Parsing flags", myFuncName)
	config.flagParser = arg.MustParse(&config.flagSettings)

	// Apply initial logging settings based on any provided CLI flags. If not
	// specified, default logging settings are used. This is done to permit
	// debug logging to be enabled prior to loading config file settings.
	config.configureLogging()

	//
	// Attempt to load requested config file, fallback to known alternates
	// if user did not specify a config file
	//

	if err := config.Load(); err != nil {
		return nil, fmt.Errorf(
			"%s: failed to load config file: %w",
			myFuncName,
			err,
		)
	}

	// Apply logging settings based on any provided config file settings. If
	// no logging settings were previously provided via CLI flags this allows
	// for config file specified settings to be applied.
	config.configureLogging()

	log.Debug("Validating configuration ...")
	if err := config.Validate(); err != nil {
		return nil, err
	}
	log.Debug("Configuration validated")

	// log.Debugf("Config object: %v", config.String())

	return &config, nil

}
// NewConfig is a factory function that produces a new Config object based
// on user provided flag and config file values.
NewConfig is a factory function that produces a new Config object based
on user provided flag and config file values.
// NewConfig is a factory function that produces a new Config object based // on user provided flag and config file values .
func NewConfig() (*Config, error) {
	myFuncName := caller.GetFuncName()
	var config Config
	log.Debugf("%s: Parsing flags", myFuncName)
	config.flagParser = arg.MustParse(&config.flagSettings)
	config.configureLogging()
	 Attempt to load requested config file, fallback to known alternates
	 if user did not specify a config file
	if err := config.Load(); err != nil {
		return nil, fmt.Errorf(
			"%s: failed to load config file: %w",
			myFuncName,
			err,
		)
	}
	 Apply logging settings based on any provided config file settings. If
	 no logging settings were previously provided via CLI flags this allows
	 for config file specified settings to be applied.
	config.configureLogging()
	log.Debug("Validating configuration ...")
	if err := config.Validate(); err != nil {
		return nil, err
	}
	log.Debug("Configuration validated")
	 log.Debugf("Config object: %v", config.String())
	return &config, nil
}
func NewConfig ( ) ( * Config , error ) { myFuncName := caller . GetFuncName ( ) var config Config log . Debugf ( " " , myFuncName ) config . flagParser = arg . MustParse ( & config . flagSettings ) config . configureLogging ( ) if err := config . Load ( ) ; err != nil { return nil , fmt . Errorf ( " " , myFuncName , err , ) } config . configureLogging ( ) log . Debug ( " " ) if err := config . Validate ( ) ; err != nil { return nil , err } log . Debug ( " " ) return & config , nil }
NewConfig is a factory function that produces a new Config object based
on user provided flag and config file values.
NewConfig is a factory function that produces a new Config object based on user provided flag and config file values .
// Bundle the returned `*.arg.Parser` for later use from `main()` so that // we can explicitly display usage or help details should the // user-provided settings fail validation. // Apply initial logging settings based on any provided CLI flags. If not // specified, default logging settings are used. This is done to permit // debug logging to be enabled prior to loading config file settings. // // Attempt to load requested config file, fallback to known alternates // if user did not specify a config file // // Apply logging settings based on any provided config file settings. If // no logging settings were previously provided via CLI flags this allows // for config file specified settings to be applied. // log.Debugf("Config object: %v", config.String())