diff options
| author | Shulhan <ms@kilabit.info> | 2024-03-03 04:59:34 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-03-05 14:53:12 +0700 |
| commit | 2fa7605727e90ca323b7b24168632e485d74c583 (patch) | |
| tree | 3533df0fc07ef96b1564736926cc3310994be515 /lib/test/data.go | |
| parent | b921ebfb3e81b367ff24305eb18c5dd073b38635 (diff) | |
| download | pakakeh.go-2fa7605727e90ca323b7b24168632e485d74c583.tar.xz | |
all: comply with linter recommendations #2
HTTP request now implicitly create request with context.
Any false positive related to not closing HTTP response body has been
annotated with "nolint:bodyclose".
In the example code, use consistent "// Output:" comment format, by
prefixing with single space.
Any comment on code now also prefixing with single space.
An error returned without variables now use [errors.New] instead of
[fmt.Errorf].
Any error returned using [fmt.Errorf] now wrapped using "%w" instead of
"%s".
Also, replace error checking using [errors.Is] or [errors.As], instead
of using equal/not-equal operator.
Any statement like "x = x OP y" now replaced with "x OP= y".
Also, swap statement is simplified using "x, y = y, x".
Any switch statement with single case now replaced with if-condition.
Any call to defer on function or program that call [os.Exit], now
replaced by calling the deferred function directly.
Any if-else condition now replaced with switch statement, if possible.
Diffstat (limited to 'lib/test/data.go')
| -rw-r--r-- | lib/test/data.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/test/data.go b/lib/test/data.go index a280b94e..4ef71877 100644 --- a/lib/test/data.go +++ b/lib/test/data.go @@ -133,7 +133,6 @@ func LoadDataDir(path string) (listData []*Data, err error) { dir *os.File listfi []os.FileInfo - listTestTxt []string fi os.FileInfo data *Data name string @@ -150,6 +149,8 @@ func LoadDataDir(path string) (listData []*Data, err error) { return nil, fmt.Errorf("%s: %w", logp, err) } + var listTestTxt = make([]string, 0, len(listfi)) + for _, fi = range listfi { if fi.Size() == 0 || fi.IsDir() { continue @@ -164,7 +165,6 @@ func LoadDataDir(path string) (listData []*Data, err error) { pathTestTxt = filepath.Join(path, name) listTestTxt = append(listTestTxt, pathTestTxt) } - if len(listTestTxt) == 0 { return listData, nil } |
