Skip to content

Commit

Permalink
config: Remove unused err return on config parser.
Browse files Browse the repository at this point in the history
This removes the unused error return from the newConfigParser function
and updates the callers accordingly.
  • Loading branch information
davecgh authored and jholdstock committed Sep 12, 2023
1 parent 3387870 commit ca751f2
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,8 @@ func genCertPair(certFile, keyFile string) error {
}

// newConfigParser returns a new command line flags parser.
func newConfigParser(cfg *config, options flags.Options) (*flags.Parser, error) {
parser := flags.NewParser(cfg, options)
return parser, nil
func newConfigParser(cfg *config, options flags.Options) *flags.Parser {
return flags.NewParser(cfg, options)
}

// cleanAndExpandPath expands environment variables and leading ~ in the
Expand Down Expand Up @@ -370,13 +369,8 @@ func loadConfig() (*config, []string, error) {
// help message error can be ignored here since they will be caught by
// the final parse below.
preCfg := cfg
preParser, err := newConfigParser(&preCfg, flags.HelpFlag)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}

_, err = preParser.Parse()
preParser := newConfigParser(&preCfg, flags.HelpFlag)
_, err := preParser.Parse()
if err != nil {
var e *flags.Error
if errors.As(err, &e) {
Expand Down Expand Up @@ -491,12 +485,7 @@ func loadConfig() (*config, []string, error) {

// Load additional config from file.
var configFileError error
parser, err := newConfigParser(&cfg, flags.Default)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return nil, nil, err
}

parser := newConfigParser(&cfg, flags.Default)
err = flags.NewIniParser(parser).ParseFile(preCfg.ConfigFile)
if err != nil {
var e *os.PathError
Expand Down

0 comments on commit ca751f2

Please sign in to comment.