Skip to content

Commit

Permalink
minor improve
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmashko committed Sep 14, 2023
1 parent 80d4c5a commit 828f9a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions external.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ type External interface {

type emptyExt struct{}

func (c *emptyExt) TagName() string {
func (emptyExt) TagName() string {
return ""
}

func (c *emptyExt) Unmarshal(v interface{}) error { return nil }
func (emptyExt) Unmarshal(v interface{}) error { return nil }

type externalConfig struct {
s *structType
Expand All @@ -35,6 +35,9 @@ func newExternalConfig(ext External) *externalConfig {
}

func (c *externalConfig) Unmarshal(v interface{}) error {
if c.ext == (emptyExt{}) {
return nil
}
mp := make(map[string]interface{})
err := c.ext.Unmarshal(&mp)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type EnvConf struct {
}

func New() *EnvConf {
return NewWithExternal(&emptyExt{})
return NewWithExternal(emptyExt{})
}

func NewWithExternal(e External) *EnvConf {
Expand Down

0 comments on commit 828f9a8

Please sign in to comment.