diff --git a/charset-reader.go b/charset-reader.go index 77a9818..41c59d6 100644 --- a/charset-reader.go +++ b/charset-reader.go @@ -15,15 +15,11 @@ func charsetReader(charset string, input io.Reader) (io.Reader, error) { case isCharsetISO88591(charset): return newCharsetISO88591(input), nil default: - decoder := mahonia.NewDecoder(charset) - if decoder == nil { - goto invalidCharset + if decoder := mahonia.NewDecoder(charset); decoder != nil { + return decoder.NewReader(input), nil } - - return decoder.NewReader(input), nil } -invalidCharset: return nil, errors.New("CharsetReader: unexpected charset: " + charset) }