Merge pull request #41 from multiformats/fix-staticcheck

fix staticcheck
This commit is contained in:
Marten Seemann
2021-05-05 20:16:15 +07:00
committed by GitHub

View File

@@ -14,7 +14,7 @@ type Encoder struct {
func NewEncoder(base Encoding) (Encoder, error) { func NewEncoder(base Encoding) (Encoder, error) {
_, ok := EncodingToStr[base] _, ok := EncodingToStr[base]
if !ok { if !ok {
return Encoder{-1}, fmt.Errorf("Unsupported multibase encoding: %d", base) return Encoder{-1}, fmt.Errorf("unsupported multibase encoding: %d", base)
} }
return Encoder{base}, nil return Encoder{base}, nil
} }
@@ -33,9 +33,9 @@ func MustNewEncoder(base Encoding) Encoder {
// either be the multibase name or single character multibase prefix // either be the multibase name or single character multibase prefix
func EncoderByName(str string) (Encoder, error) { func EncoderByName(str string) (Encoder, error) {
var base Encoding var base Encoding
ok := true var ok bool
if len(str) == 0 { if len(str) == 0 {
return Encoder{-1}, fmt.Errorf("Empty multibase encoding") return Encoder{-1}, fmt.Errorf("empty multibase encoding")
} else if len(str) == 1 { } else if len(str) == 1 {
base = Encoding(str[0]) base = Encoding(str[0])
_, ok = EncodingToStr[base] _, ok = EncodingToStr[base]
@@ -43,7 +43,7 @@ func EncoderByName(str string) (Encoder, error) {
base, ok = Encodings[str] base, ok = Encodings[str]
} }
if !ok { if !ok {
return Encoder{-1}, fmt.Errorf("Unsupported multibase encoding: %s", str) return Encoder{-1}, fmt.Errorf("unsupported multibase encoding: %s", str)
} }
return Encoder{base}, nil return Encoder{base}, nil
} }