From 1ff8b3fd947fc98d14d2295c61bbc4906f0b3fe3 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 16 Nov 2020 17:54:43 +0300 Subject: [PATCH] [#199] sdk/object: Correct linter's remarks Signed-off-by: Leonard Lyubich --- pkg/object/fmt.go | 8 ++++++-- pkg/object/search.go | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/object/fmt.go b/pkg/object/fmt.go index 0432195..0ada68b 100644 --- a/pkg/object/fmt.go +++ b/pkg/object/fmt.go @@ -10,6 +10,10 @@ import ( "github.com/pkg/errors" ) +var errCheckSumMismatch = errors.New("payload checksum mismatch") + +var errIncorrectID = errors.New("incorrect object identifier") + // CalculatePayloadChecksum calculates and returns checksum of // object payload bytes. func CalculatePayloadChecksum(payload []byte) *pkg.Checksum { @@ -34,7 +38,7 @@ func VerifyPayloadChecksum(obj *Object) error { obj.PayloadChecksum(), CalculatePayloadChecksum(obj.Payload()), ) { - return errors.New("payload checksum mismatch") + return errCheckSumMismatch } return nil @@ -75,7 +79,7 @@ func VerifyID(obj *Object) error { } if !id.Equal(obj.ID()) { - return errors.New("incorrect object identifier") + return errIncorrectID } return nil diff --git a/pkg/object/search.go b/pkg/object/search.go index d2cb849..b9383e2 100644 --- a/pkg/object/search.go +++ b/pkg/object/search.go @@ -138,6 +138,7 @@ func NewSearchFilters() SearchFilters { func NewSearchFiltersFromV2(v2 []*v2object.SearchFilter) SearchFilters { filters := make(SearchFilters, 0, len(v2)) + for i := range v2 { if v2[i] == nil { continue @@ -197,6 +198,7 @@ func (f *SearchFilters) AddObjectOwnerIDFilter(m SearchMatchType, id *owner.ID) func (f SearchFilters) ToV2() []*v2object.SearchFilter { result := make([]*v2object.SearchFilter, 0, len(f)) + for i := range f { v2 := new(v2object.SearchFilter) v2.SetKey(f[i].header.String())