Address staticcheck issues

Fix `staticcheck` issues:
- S1028 use `fmt.Errorf` to construct formatted errors
- ST1017 yoda conditions
- ST1005 error message capitalization
- ST1006 avoid `self` as receiver name
- S1030 use `buf.String`
- S1011 avoid redundant loop when `append` suffices
- SA4006 unused value
- S1019 remove redundant capacity on `make` call
- SA2002 `t.Fatal` called outside of test

Exported error violates ST1012, which is ignored by this PR since rename may cause breaking changes.

Remove redundant parentheses wrapping, and use CamelCase naming while at it.
This commit is contained in:
Masih H. Derkani
2021-07-19 16:47:21 +01:00
parent 6f65c2c3af
commit 597b8983b0
20 changed files with 196 additions and 212 deletions

View File

@@ -74,7 +74,7 @@ func (h *HMAC) Write(data []byte) (n int, err error) {
}
func (h *HMAC) Reset() error {
if 1 != C.X_HMAC_Init_ex(h.ctx, nil, 0, nil, nil) {
if C.X_HMAC_Init_ex(h.ctx, nil, 0, nil, nil) != 1 {
return errors.New("failed to reset HMAC_CTX")
}
return nil