diff options
author | Matthew Holt <[email protected]> | 2019-05-21 14:22:21 -0600 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2019-05-21 14:22:21 -0600 |
commit | 2fd98cb040b617d2a018ae00a3a68b320de7dbc6 (patch) | |
tree | 91de4d369ec2a94c8f4fc3de4ba256945ad50297 /context.go | |
parent | 67d32e6779b8e4f67fb0902b06210596371ead7f (diff) | |
download | caddy-2fd98cb040b617d2a018ae00a3a68b320de7dbc6.tar.gz caddy-2fd98cb040b617d2a018ae00a3a68b320de7dbc6.zip |
Module.New() does not need to return an error
Diffstat (limited to 'context.go')
-rw-r--r-- | context.go | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/context.go b/context.go index e437f08ca..bdf9f6056 100644 --- a/context.go +++ b/context.go @@ -75,10 +75,7 @@ func (ctx Context) LoadModule(name string, rawMsg json.RawMessage) (interface{}, return nil, fmt.Errorf("module '%s' has no constructor", mod.Name) } - val, err := mod.New() - if err != nil { - return nil, fmt.Errorf("initializing module '%s': %v", mod.Name, err) - } + val := mod.New() // value must be a pointer for unmarshaling into concrete type if rv := reflect.ValueOf(val); rv.Kind() != reflect.Ptr { @@ -87,7 +84,7 @@ func (ctx Context) LoadModule(name string, rawMsg json.RawMessage) (interface{}, // fill in its config only if there is a config to fill in if len(rawMsg) > 0 { - err = json.Unmarshal(rawMsg, &val) + err := json.Unmarshal(rawMsg, &val) if err != nil { return nil, fmt.Errorf("decoding module config: %s: %v", mod.Name, err) } |