Skip to content

Commit

Permalink
stylistic cleanups, 1 for golint, 1 for me
Browse files Browse the repository at this point in the history
I blinked at `e := ...; return e`, so that gets cleaned up.

The `golint` tool complained:

    redundant if ...; err != nil check, just return error instead.

I went one better and just return the result of the function directly.
  • Loading branch information
philpennock committed Feb 24, 2018
1 parent 4a4cc36 commit 5449e85
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions decode.go
Expand Up @@ -67,11 +67,10 @@ func swallowRuneToken(decoder *json.Decoder, expect rune, failExpect SwallowErro
return err
}
if t != json.Delim(expect) {
e := SwallowError{
return SwallowError{
s: failExpect.s,
aux: fmt.Sprintf("expected %q got %q", expect, t),
}
return e
}
return nil
}
Expand Down Expand Up @@ -177,9 +176,6 @@ func UnmarshalWith(target interface{}, spilloverName string, raw []byte) error {
spillInto.SetMapIndex(kv, vv.Convert(spillValueType))
}
}
if err := swallowRuneToken(dec, '}', ErrMalformedJSON); err != nil {
return err
}

return nil
return swallowRuneToken(dec, '}', ErrMalformedJSON)
}

0 comments on commit 5449e85

Please sign in to comment.