chore: lint code with golangci-lint (#1828)

* feat: add golangci-lint linting

* chore: fix linter issues

* feat: add linting into the workflow

* docs: update lint docs

* fix: cr suggestions

* fix: remove old formatting and vetting scripts

* fix: add docker make target

* fix: action go caching

* fix: depreciated actions checkout version

* fix: cr suggestion

* fix: cr suggestions

---------

Co-authored-by: Manu Gupta <manugupt1@gmail.com>
This commit is contained in:
Nicholas Wiersma
2023-02-25 06:39:17 +02:00
committed by GitHub
parent 66582eebfe
commit d932d50232
134 changed files with 596 additions and 600 deletions
+6 -6
View File
@@ -13,7 +13,7 @@ import (
"github.com/gomods/athens/pkg/storage"
)
// Info implements the (./pkg/storage).Getter interface
// Info implements the (./pkg/storage).Getter interface.
func (s *Storage) Info(ctx context.Context, module, version string) ([]byte, error) {
const op errors.Op = "s3.Info"
ctx, span := observ.StartSpan(ctx, op.String())
@@ -30,7 +30,7 @@ func (s *Storage) Info(ctx context.Context, module, version string) ([]byte, err
if err != nil {
return nil, errors.E(op, err, errors.M(module), errors.V(version))
}
defer infoReader.Close()
defer func() { _ = infoReader.Close() }()
infoBytes, err := io.ReadAll(infoReader)
if err != nil {
@@ -39,7 +39,7 @@ func (s *Storage) Info(ctx context.Context, module, version string) ([]byte, err
return infoBytes, nil
}
// GoMod implements the (./pkg/storage).Getter interface
// GoMod implements the (./pkg/storage).Getter interface.
func (s *Storage) GoMod(ctx context.Context, module, version string) ([]byte, error) {
const op errors.Op = "s3.GoMod"
ctx, span := observ.StartSpan(ctx, op.String())
@@ -56,17 +56,17 @@ func (s *Storage) GoMod(ctx context.Context, module, version string) ([]byte, er
if err != nil {
return nil, errors.E(op, err, errors.M(module), errors.V(version))
}
defer modReader.Close()
defer func() { _ = modReader.Close() }()
modBytes, err := io.ReadAll(modReader)
if err != nil {
return nil, errors.E(op, fmt.Errorf("could not get new reader for mod file: %s", err), errors.M(module), errors.V(version))
return nil, errors.E(op, fmt.Errorf("could not get new reader for mod file: %w", err), errors.M(module), errors.V(version))
}
return modBytes, nil
}
// Zip implements the (./pkg/storage).Getter interface
// Zip implements the (./pkg/storage).Getter interface.
func (s *Storage) Zip(ctx context.Context, module, version string) (storage.SizeReadCloser, error) {
const op errors.Op = "s3.Zip"
ctx, span := observ.StartSpan(ctx, op.String())