diff options
| author | Shulhan <ms@kilabit.info> | 2024-03-04 03:01:45 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-03-05 16:21:51 +0700 |
| commit | 7ec26b9f98b5af909e935b69fbaa1db17d89cf6a (patch) | |
| tree | 40e4ba41bc116bfbeb5cb526c8d8b1fcede8d669 /lib/memfs/memfs_test.go | |
| parent | 2fa7605727e90ca323b7b24168632e485d74c583 (diff) | |
| download | pakakeh.go-7ec26b9f98b5af909e935b69fbaa1db17d89cf6a.tar.xz | |
all: comply with linter recommendations #3
For HTTP server that use TLS, set the minimum TLS version and
ReadHeaderTimeout to mitigate slowloris attack.
For HTTP client or server that parameterize the use of InsecureSkipVerify,
annotate the line with "nolint:gosec" to allow the code pass the check.
Library that still use sha1, in example in DKIM and TOTP, skip the
warnings by annotating the line with "nolint:gosec".
A pointer variable now allocated their address before assigning its
value.
Any error that returned now wrapped using "%w".
Also, replace error checking using [errors.Is] or [errors.As] instead of
using equal or not-equal operators.
In "lib/http", replace any usage of "math/rand" with "crypto/rand".
Any call of [math/big.Rat.SetString] now annotated with "nolint:gosec"
since its false positive, the issue has been fixed in Go >= 1.17.7.
Any switch case that does not cover the rest of the possible values now
handled by adding the cases or by replacing the "default" case with
the rest of values.
Diffstat (limited to 'lib/memfs/memfs_test.go')
| -rw-r--r-- | lib/memfs/memfs_test.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/memfs/memfs_test.go b/lib/memfs/memfs_test.go index abd5847d..efed74a9 100644 --- a/lib/memfs/memfs_test.go +++ b/lib/memfs/memfs_test.go @@ -38,7 +38,7 @@ func TestMain(m *testing.M) { if !errors.As(err, &perr) { log.Fatal("!ok:", err) } - if perr.Err != os.ErrExist { + if !errors.Is(perr.Err, os.ErrExist) { log.Fatalf("perr: %+v %+v\n", perr.Err, os.ErrExist) } } @@ -49,7 +49,7 @@ func TestMain(m *testing.M) { if !errors.As(err, &perr) { log.Fatal(err) } - if perr.Err != os.ErrExist { + if !errors.Is(perr.Err, os.ErrExist) { log.Fatal(err) } } @@ -151,10 +151,14 @@ func TestNew(t *testing.T) { }, }} + var ( + mfs *MemFS + err error + ) for _, c := range cases { t.Log(c.desc) - mfs, err := New(&c.opts) + mfs, err = New(&c.opts) if err != nil { test.Assert(t, "error", c.expErr, err.Error()) continue |
