Skip to content

Commit

Permalink
does not return error while loader is nil (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktong authored Mar 4, 2024
1 parent 78306dd commit 5181b85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
15 changes: 5 additions & 10 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package konf

import (
"errors"
"fmt"
"log/slog"
"slices"
Expand Down Expand Up @@ -59,7 +58,7 @@ func (c *Config) Load(loader Loader) error {
c.nocopy.Check()

if loader == nil {
return errNilLoader
return nil
}

if c.values == nil {
Expand Down Expand Up @@ -201,12 +200,8 @@ type provider struct {
values map[string]any
}

var (
errNilLoader = errors.New("cannot load config from nil loader")

defaultDecodeHook = mapstructure.ComposeDecodeHookFunc( //nolint:gochecknoglobals
mapstructure.StringToTimeDurationHookFunc(),
mapstructure.StringToSliceHookFunc(","),
mapstructure.TextUnmarshallerHookFunc(),
)
var defaultDecodeHook = mapstructure.ComposeDecodeHookFunc( //nolint:gochecknoglobals
mapstructure.StringToTimeDurationHookFunc(),
mapstructure.StringToSliceHookFunc(","),
mapstructure.TextUnmarshallerHookFunc(),
)
1 change: 0 additions & 1 deletion config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func TestConfig_Load(t *testing.T) {
},
{
description: "nil loader",
err: "cannot load config from nil loader",
},
}

Expand Down

0 comments on commit 5181b85

Please sign in to comment.