diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ed895f4..e4b7642 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -31,8 +31,8 @@ jobs: name: Lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: cache: true go-version-file: "go.mod" diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..12347ae --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,28 @@ +name: golangci-lint +on: + push: + branches: [main, development] + pull_request: + branches: [main, development] + +permissions: + contents: read + pull-requests: read + checks: write + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: '1.23' + + - name: golangci-lint + uses: golangci/golangci-lint-action@9fae48acfc02a90574d7c304a1758ef9895495fa # v7.0.1 + with: + version: v2.4.0 + args: --config .golangci.yml \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index 1121b6a..76381eb 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,4 +1,4 @@ -# Copyright 2019 Iguazio +# Copyright 2025 Iguazio # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,35 +12,54 @@ # See the License for the specific language governing permissions and # limitations under the License. # +version: "2" + +run: + timeout: 5m + build-tags: + - test_unit + - test_integration + linters: - disable-all: true + default: none enable: - - gofmt - - revive - - gosimple + - errcheck + - goconst + - gocritic + - govet - ineffassign - misspell - staticcheck - unconvert - - vet - - vetshadow - - errcheck - -run: - - # timeout for analysis - timeout: 10m - - skip-dirs: - - hack - - docs - - test - - vendor + - unused + disable: [] + # All linters are enabled - using //nolint directives in code instead + + exclusions: + paths: + - "docs" + - "hack" + rules: + - linters: [goconst] + path: "_test\\.go" + - path: "(.+)\\.go$" + text: "comment on" + - path: "(.+)\\.go$" + text: "error should be the last" -issues: + settings: + gocritic: + disabled-checks: + - commentFormatting - # List of regexps of issue texts to exclude - exclude: - - "comment on" - - "error should be the last" - - "should have comment" +formatters: + settings: + gci: + sections: + - standard + - "prefix(github.com/v3io/)" + - "prefix(github.com/nuclio/)" + - default + - blank + - dot + custom-order: true \ No newline at end of file diff --git a/Makefile b/Makefile index 0a7d99b..08d7a10 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,80 @@ -# Copyright 2019 Iguazio +# Copyright 2025 The v3io-go Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +GO_VERSION := $(shell go version | cut -d " " -f 3) +GOPATH ?= $(shell go env GOPATH) +SHELL := /bin/bash + +# Get default os / arch from go env +V3IO_DEFAULT_OS := $(shell go env GOOS) +V3IO_DEFAULT_ARCH := $(shell go env GOARCH || echo amd64) + +V3IO_OS := $(if $(V3IO_OS),$(V3IO_OS),$(V3IO_DEFAULT_OS)) +V3IO_ARCH := $(if $(V3IO_ARCH),$(V3IO_ARCH),$(V3IO_DEFAULT_ARCH)) + +# Version information +V3IO_VERSION_GIT_COMMIT = $(shell git rev-parse HEAD) +V3IO_PATH ?= $(shell pwd) + +# Link flags +GO_LINK_FLAGS ?= -s -w + +# Go test timeout +V3IO_GO_TEST_TIMEOUT ?= "30m" + +# +# Must be first target +# +.PHONY: all +all: + $(error "Please pick a target (run 'make targets' to view targets)") + +# +# Linting and formatting +# +.PHONY: fmt +fmt: ensure-golangci-linter + gofmt -s -w . + $(GOLANGCI_LINT_BIN) run --fix + +.PHONY: lint +lint: modules ensure-golangci-linter + @echo Linting... + $(GOLANGCI_LINT_BIN) run -v + @echo Done. + + +GOLANGCI_LINT_VERSION := 2.3.0 +GOLANGCI_LINT_BIN := $(CURDIR)/.bin/golangci-lint +GOLANGCI_LINT_INSTALL_COMMAND := GOBIN=$(CURDIR)/.bin go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v$(GOLANGCI_LINT_VERSION) + +.PHONY: ensure-golangci-linter +ensure-golangci-linter: + @if ! command -v $(GOLANGCI_LINT_BIN) >/dev/null 2>&1; then \ + echo "golangci-lint not found. Installing..."; \ + $(GOLANGCI_LINT_INSTALL_COMMAND); \ + else \ + installed_version=$$($(GOLANGCI_LINT_BIN) version | awk '/version/ {gsub(/^v/, "", $$4); print $$4}'); \ + if [ "$$installed_version" != "$(GOLANGCI_LINT_VERSION)" ]; then \ + echo "golangci-lint version mismatch ($$installed_version != $(GOLANGCI_LINT_VERSION)). Reinstalling..."; \ + $(GOLANGCI_LINT_INSTALL_COMMAND); \ + fi \ + fi + +# +# Environment validation # -# To setup env locally on your dev box, run: -# $ export $(grep -v '^#' ./hack/test.env | xargs) .PHONY: check-env check-env: ifndef V3IO_DATAPLANE_URL @@ -39,45 +100,70 @@ ifndef V3IO_CONTROLPLANE_IGZ_ADMIN_PASSWORD endif @echo "All required env vars populated" +# +# Schema generation +# .PHONY: generate-capnp generate-capnp: - pushd ./pkg/dataplane/schemas/; ./build; popd + @echo "Generating Cap'n Proto schemas..." + @cd ./pkg/dataplane/schemas/; ./build + @echo "Schema generation complete." -.PHONY: clean -clean: - pushd ./pkg/dataplane/schemas/; ./clean; popd +.PHONY: clean-schemas +clean-schemas: + @echo "Cleaning generated schemas..." + @cd ./pkg/dataplane/schemas/; ./clean + @echo "Schema cleanup complete." -.PHONY: fmt -fmt: - gofmt -s -w . +# +# Building +# +.PHONY: build-lib +build-lib: modules + @echo "Building v3io-go library..." + @go build ./pkg/... + @echo "Library build successful." -.PHONY: lint -lint: - ./hack/lint/install.sh - ./hack/lint/run.sh +.PHONY: build +build: clean-schemas generate-capnp build-lib lint test + @echo "Full build pipeline complete." -.PHONY: test -test: check-env - go test -race -tags unit -count 1 ./... +# +# Testing +# +.PHONY: test-unit +test-unit: modules ensure-gopath + go test -race -tags=test_unit -v ./pkg/... -short + +.PHONY: test-integration +test-integration: modules ensure-gopath + go test -race -tags=test_integration -v ./pkg/... --timeout $(V3IO_GO_TEST_TIMEOUT) + +.PHONY: test-coverage +test-coverage: + go test -tags=test_unit -coverprofile=coverage.out ./pkg/... || go tool cover -html=coverage.out .PHONY: test-controlplane -test-controlplane: check-env - go test -test.v=true -race -tags unit -count 1 ./pkg/controlplane/... +test-controlplane: modules ensure-gopath check-env + go test -test.v=true -race -tags=test_unit -count=1 ./pkg/controlplane/... .PHONY: test-dataplane -test-dataplane: check-env - go test -test.v=true -race -tags unit -count 1 ./pkg/dataplane/... +test-dataplane: modules ensure-gopath check-env + go test -test.v=true -race -tags=test_unit -count=1 ./pkg/dataplane/... .PHONY: test-dataplane-simple -test-dataplane-simple: check-env - go test -test.v=true -tags unit -count 1 ./pkg/dataplane/... +test-dataplane-simple: modules ensure-gopath check-env + go test -test.v=true -tags=test_unit -count=1 ./pkg/dataplane/... .PHONY: test-system test-system: test-controlplane test-dataplane-simple +.PHONY: test +test: test-unit + .PHONY: build-test-container build-test-container: - @echo Building test container... + @echo "Building test container..." docker build \ --file hack/test/docker/Dockerfile \ --tag v3io-go-test:latest \ @@ -87,15 +173,50 @@ build-test-container: test-system-in-docker: build-test-container @echo "Running system test in docker container..." docker run --rm \ - --env V3IO_DATAPLANE_URL="${V3IO_DATAPLANE_URL}" \ - --env V3IO_DATAPLANE_USERNAME="${V3IO_DATAPLANE_USERNAME}" \ - --env V3IO_DATAPLANE_ACCESS_KEY="${V3IO_DATAPLANE_ACCESS_KEY}" \ - --env V3IO_CONTROLPLANE_URL="${V3IO_CONTROLPLANE_URL}" \ - --env V3IO_CONTROLPLANE_USERNAME="${V3IO_CONTROLPLANE_USERNAME}" \ - --env V3IO_CONTROLPLANE_PASSWORD="${V3IO_CONTROLPLANE_PASSWORD}" \ - --env V3IO_CONTROLPLANE_IGZ_ADMIN_PASSWORD="${V3IO_CONTROLPLANE_IGZ_ADMIN_PASSWORD}" \ + --env V3IO_DATAPLANE_URL="$(V3IO_DATAPLANE_URL)" \ + --env V3IO_DATAPLANE_USERNAME="$(V3IO_DATAPLANE_USERNAME)" \ + --env V3IO_DATAPLANE_ACCESS_KEY="$(V3IO_DATAPLANE_ACCESS_KEY)" \ + --env V3IO_CONTROLPLANE_URL="$(V3IO_CONTROLPLANE_URL)" \ + --env V3IO_CONTROLPLANE_USERNAME="$(V3IO_CONTROLPLANE_USERNAME)" \ + --env V3IO_CONTROLPLANE_PASSWORD="$(V3IO_CONTROLPLANE_PASSWORD)" \ + --env V3IO_CONTROLPLANE_IGZ_ADMIN_PASSWORD="$(V3IO_CONTROLPLANE_IGZ_ADMIN_PASSWORD)" \ v3io-go-test:latest make test-system - @echo Done. + @echo "Docker test complete." -.PHONY: build -build: clean generate-capnp lint test +# +# Go modules and environment +# +.PHONY: ensure-gopath +ensure-gopath: +ifndef GOPATH + $(error GOPATH must be set) +endif + +.PHONY: modules +modules: ensure-gopath + @go mod download + +.PHONY: tidy +tidy: + @go mod tidy + +.PHONY: clean +clean: clean-schemas + @echo "Cleaning build artifacts..." + @go clean -cache + @rm -rf .bin/ + @rm -rf coverage.out + @echo "Clean complete." + +.PHONY: targets +targets: + @awk -F: '/^[^ \t="]+:/ && !/PHONY/ {print $$1}' Makefile | sort -u + +# +# Versioning +# +.PHONY: version +version: + @echo "Git commit: $(V3IO_VERSION_GIT_COMMIT)" + @echo "Go version: $(GO_VERSION)" + @echo "OS/Arch: $(V3IO_OS)/$(V3IO_ARCH)" \ No newline at end of file diff --git a/go.mod b/go.mod index b7ea4db..8df2493 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/v3io/v3io-go -go 1.19 +go 1.23 require ( github.com/nuclio/errors v0.0.4 diff --git a/hack/test/docker/Dockerfile b/hack/test/docker/Dockerfile index 93c9747..ae45e20 100644 --- a/hack/test/docker/Dockerfile +++ b/hack/test/docker/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -FROM gcr.io/iguazio/golang:1.19 +FROM gcr.io/iguazio/golang:1.23 ENV GOPATH=/go WORKDIR /v3io-go diff --git a/pkg/controlplane/http/session.go b/pkg/controlplane/http/session.go index 90427e2..538d370 100644 --- a/pkg/controlplane/http/session.go +++ b/pkg/controlplane/http/session.go @@ -503,7 +503,7 @@ func (s *session) GetJob(getJobsInput *v3ioc.GetJobInput) (*v3ioc.GetJobOutput, return &getJobsOutput, err } -func (s *session) getResourceDetail(ctx context.Context, +func (s *session) getResourceDetail(ctx context.Context, //nolint:unused path string, controlPlaneInput *v3ioc.ControlPlaneInput, controlPlaneOutput *v3ioc.ControlPlaneOutput, @@ -826,7 +826,7 @@ func (s *session) sendRequest(ctx context.Context, request *request, timeout tim } // check if we got any cookies to set - httpResponse.Header.VisitAllCookie(func(key []byte, value []byte) { + httpResponse.Header.VisitAllCookie(func(key []byte, value []byte) { //nolint:staticcheck // SA1019 responseInstance.cookies = map[string]string{} responseInstance.cookies[string(key)] = string(value) }) @@ -841,7 +841,7 @@ func (s *session) sendRequest(ctx context.Context, request *request, timeout tim if !request.allowErrors { if responseInstance.statusCode >= 300 { return nil, v3ioerrors.NewErrorWithStatusCode( - fmt.Errorf("Failed to execute HTTP request %s/%s.\nResponse code: %d", + fmt.Errorf("Failed to execute HTTP request %s/%s.\nResponse code: %d", //nolint:staticcheck // ST1005 s.endpoints[0], request.path, responseInstance.statusCode), responseInstance.statusCode) } diff --git a/pkg/controlplane/test/controlplane_test.go b/pkg/controlplane/test/controlplane_test.go index f0c08b3..c41a909 100644 --- a/pkg/controlplane/test/controlplane_test.go +++ b/pkg/controlplane/test/controlplane_test.go @@ -112,7 +112,7 @@ func (suite *testSuite) TearDownSuite() { } func (suite *testSuite) SetupTest() { - suite.ctx = context.WithValue(context.TODO(), "RequestID", "test-0") + suite.ctx = context.WithValue(context.TODO(), "RequestID", "test-0") //nolint:staticcheck // SA1029 } func (suite *testSuite) TestCreateContainer() { diff --git a/pkg/dataplane/http/context.go b/pkg/dataplane/http/context.go index 3d5e51d..4a3d503 100755 --- a/pkg/dataplane/http/context.go +++ b/pkg/dataplane/http/context.go @@ -200,7 +200,7 @@ func (c *context) GetContainerContentsSync(getContainerContentsInput *v3io.GetCo if getContainerContentsInput.Path != "" { queryBuilder.WriteString("prefix=") encodedPrefix := url.QueryEscape(getContainerContentsInput.Path) - encodedPrefix = strings.Replace(encodedPrefix, "+", "%20", -1) + encodedPrefix = strings.Replace(encodedPrefix, "+", "%20", -1) //nolint:gocritic,staticcheck // wrapperFunc, QF1004 queryBuilder.WriteString(encodedPrefix) } @@ -359,9 +359,9 @@ func (c *context) GetItemsSync(getItemsInput *v3io.GetItemsInput) (*v3io.Respons headers[k] = v } - if len(getItemsInput.DataPlaneInput.MtimeSec) > 0 { - headers["conditional-mtime-sec"] = getItemsInput.DataPlaneInput.MtimeSec - headers["conditional-mtime-nsec"] = getItemsInput.DataPlaneInput.MtimeNsec + if len(getItemsInput.DataPlaneInput.MtimeSec) > 0 { //nolint:staticcheck // QF1008 + headers["conditional-mtime-sec"] = getItemsInput.DataPlaneInput.MtimeSec //nolint:staticcheck // QF1008 + headers["conditional-mtime-nsec"] = getItemsInput.DataPlaneInput.MtimeNsec //nolint:staticcheck // QF1008 } response, err := c.sendRequest(&getItemsInput.DataPlaneInput, @@ -773,7 +773,7 @@ func (c *context) SeekShardSync(seekShardInput *v3io.SeekShardInput) (*v3io.Resp buffer.WriteString(seekShardsInputTypeToString[seekShardInput.Type]) buffer.WriteString(`"`) - if seekShardInput.Type == v3io.SeekShardInputTypeSequence { + if seekShardInput.Type == v3io.SeekShardInputTypeSequence { //nolint:staticcheck // QF1003 buffer.WriteString(`, "StartingSequenceNumber": `) buffer.WriteString(strconv.FormatUint(seekShardInput.StartingSequenceNumber, 10)) } else if seekShardInput.Type == v3io.SeekShardInputTypeTime { @@ -1155,7 +1155,7 @@ func (c *context) sendRequest(dataPlaneInput *v3io.DataPlaneInput, var re = regexp.MustCompile(".*X-V3io-Session-Key:.*") sanitizedRequest := re.ReplaceAllString(request.String(), "X-V3io-Session-Key: SANITIZED") - _err := fmt.Errorf("Expected a 2xx response status code: %s\nRequest details:\n%s", + _err := fmt.Errorf("Expected a 2xx response status code: %s\nRequest details:\n%s", //nolint:staticcheck // ST1005 response.HTTPResponse.String(), sanitizedRequest) // Include response in error only if caller has requested it @@ -1200,7 +1200,7 @@ func (c *context) buildRequestURI(urlString string, containerName string, query if strings.HasSuffix(pathStr, "/") { uri.Path += "/" // retain trailing slash } - uri.RawQuery = strings.Replace(query, " ", "%20", -1) + uri.RawQuery = strings.Replace(query, " ", "%20", -1) //nolint:gocritic,staticcheck // wrapperFunc, QF1004 return uri, nil } @@ -1621,11 +1621,11 @@ func (c *context) getItemsParseCAPNPResponse(response *v3io.Response, withWildca if err != nil { return nil, errors.Wrap(err, "data.ValueMap.Values") } - accLength = accLength + dv.Len() + accLength = accLength + dv.Len() //nolint:gocritic // assignOp valuesSections[capnpSectionIndex-1].data = dv valuesSections[capnpSectionIndex-1].accumulatedPreviousSectionsLength = accLength } - accLength = accLength + values.Len() + accLength = accLength + values.Len() //nolint:gocritic // assignOp valuesSections[len(capnpSections)-2].data = values valuesSections[len(capnpSections)-2].accumulatedPreviousSectionsLength = accLength @@ -1712,7 +1712,7 @@ func parseMtimeHeader(response *v3io.Response) (int, int, error) { for _, expression := range strings.Split(mtimeHeader, "and") { mtimeParts := strings.Split(expression, "==") mtimeType := strings.TrimSpace(mtimeParts[0]) - if mtimeType == "__mtime_secs" { + if mtimeType == "__mtime_secs" { //nolint:gocritic,staticcheck // ifElseChain, QF1003 mtimeSecs, err = trimAndParseInt(mtimeParts[1]) if err != nil { return 0, 0, err diff --git a/pkg/dataplane/itemscursor.go b/pkg/dataplane/itemscursor.go index 6cb79e8..3f21c52 100644 --- a/pkg/dataplane/itemscursor.go +++ b/pkg/dataplane/itemscursor.go @@ -42,9 +42,9 @@ type ItemsCursor struct { container Container scattered bool - logger logger.Logger - retryAttempts int - retryInterval time.Duration + logger logger.Logger //nolint:unused + retryAttempts int //nolint:unused + retryInterval time.Duration //nolint:unused } func getFunctionName(fn interface{}) string { diff --git a/pkg/dataplane/streamconsumergroup/claim.go b/pkg/dataplane/streamconsumergroup/claim.go index d14cb64..c955705 100644 --- a/pkg/dataplane/streamconsumergroup/claim.go +++ b/pkg/dataplane/streamconsumergroup/claim.go @@ -127,7 +127,7 @@ func (c *claim) fetchRecordBatches(stopChannel chan struct{}, fetchInterval time c.getShardLocationAttempts, nil, &c.getShardLocationBackoff, - func(attempt int) (bool, error, int) { + func(attempt int) (bool, error, int) { //nolint:staticcheck // ST1008 c.currentShardLocation, err = c.getCurrentShardLocation(c.shardID) if err != nil { // if the error is not fatal (as network issue), diff --git a/pkg/dataplane/streamconsumergroup/streamconsumergroup.go b/pkg/dataplane/streamconsumergroup/streamconsumergroup.go index 9433d1e..e7103f0 100644 --- a/pkg/dataplane/streamconsumergroup/streamconsumergroup.go +++ b/pkg/dataplane/streamconsumergroup/streamconsumergroup.go @@ -113,7 +113,7 @@ func (scg *streamConsumerGroup) setState(modifier stateModifier, backoff := scg.config.State.ModifyRetry.Backoff attempts := scg.config.State.ModifyRetry.Attempts - err := common.RetryFunc(context.TODO(), scg.logger, attempts, nil, &backoff, func(attempt int) (bool, error, int) { + err := common.RetryFunc(context.TODO(), scg.logger, attempts, nil, &backoff, func(attempt int) (bool, error, int) { //nolint:staticcheck // ST1008 state, stateMtimeNanoSeconds, stateMtimeSeconds, err := scg.getStateFromPersistency() if err != nil && !errors.Is(err, v3ioerrors.ErrNotFound) { return true, errors.Wrap(err, "Failed getting current state from persistency"), 0 diff --git a/pkg/dataplane/test/streamconsumergroup_test.go b/pkg/dataplane/test/streamconsumergroup_test.go index 850e8a1..90cd68b 100644 --- a/pkg/dataplane/test/streamconsumergroup_test.go +++ b/pkg/dataplane/test/streamconsumergroup_test.go @@ -214,7 +214,7 @@ func (suite *streamConsumerGroupTestSuite) TestStateHandlerRetainShards() { 30, &duration, nil, - func(attempt int) (bool, error, int) { + func(attempt int) (bool, error, int) { //nolint:staticcheck // ST1008 //nolint:staticcheck // ST1008 observedState, err := streamConsumerGroup.GetState() suite.Require().NoError(err) for _, sessionState := range observedState.SessionStates { @@ -270,7 +270,7 @@ func (suite *streamConsumerGroupTestSuite) TestStateHandlerRetainShards() { 30, &duration, nil, - func(attempt int) (bool, error, int) { + func(attempt int) (bool, error, int) { //nolint:staticcheck // ST1008 //nolint:staticcheck // ST1008 observedState, err := streamConsumerGroup.GetState() suite.Require().NoError(err) @@ -368,7 +368,7 @@ func (suite *streamConsumerGroupTestSuite) TestStateHandlerAbort() { 10, &duration, nil, - func(attempt int) (bool, error, int) { + func(attempt int) (bool, error, int) { //nolint:staticcheck // ST1008 state, err = suite.getStateFromPersistency(suite.streamPath, consumerGroupName) if err != nil { suite.logger.DebugWith("State was not retrieved from persistency", @@ -391,7 +391,7 @@ func (suite *streamConsumerGroupTestSuite) TestStateHandlerAbort() { 10, &duration, nil, - func(attempt int) (bool, error, int) { + func(attempt int) (bool, error, int) { //nolint:staticcheck // ST1008 err = suite.setStateInPersistency(suite.streamPath, consumerGroupName, state) if err != nil { suite.logger.DebugWith("State was not set in persistency yet", diff --git a/pkg/dataplane/test/sync_test.go b/pkg/dataplane/test/sync_test.go index 02254ce..dd00b56 100644 --- a/pkg/dataplane/test/sync_test.go +++ b/pkg/dataplane/test/sync_test.go @@ -373,11 +373,11 @@ func (suite *syncContextContainerTestSuite) SetupSuite() { suite.createContext() } -type syncContainerContainerTestSuite struct { +type syncContainerContainerTestSuite struct { //nolint:unused syncContainerTestSuite } -func (suite *syncContainerContainerTestSuite) SetupSuite() { +func (suite *syncContainerContainerTestSuite) SetupSuite() { //nolint:unused suite.syncContainerTestSuite.SetupSuite() suite.createContainer() @@ -402,7 +402,7 @@ func (suite *syncObjectTestSuite) TestObject() { // when run against a context, will populate fields like container name suite.populateDataPlaneInput(&getObjectInput.DataPlaneInput) - response, err := suite.container.GetObjectSync(getObjectInput) + response, err := suite.container.GetObjectSync(getObjectInput) //nolint:ineffassign,staticcheck // SA4006 // get the underlying root error errWithStatusCode, errHasStatusCode := err.(v3ioerrors.ErrorWithStatusCode) @@ -415,7 +415,7 @@ func (suite *syncObjectTestSuite) TestObject() { putObjectInput := &v3io.PutObjectInput{ Path: path, - Body: []byte(contents), + Body: []byte(contents), //nolint:unconvert } // when run against a context, will populate fields like container name @@ -532,7 +532,7 @@ func (suite *syncObjectTestSuite) TestAppend() { // when run against a context, will populate fields like container name suite.populateDataPlaneInput(&getObjectInput.DataPlaneInput) - response, err := suite.container.GetObjectSync(getObjectInput) + response, err := suite.container.GetObjectSync(getObjectInput) //nolint:ineffassign,staticcheck // SA4006 // get the underlying root error errWithStatusCode, errHasStatusCode := err.(v3ioerrors.ErrorWithStatusCode) @@ -545,7 +545,7 @@ func (suite *syncObjectTestSuite) TestAppend() { putObjectInput := &v3io.PutObjectInput{ Path: path, - Body: []byte(contents), + Body: []byte(contents), //nolint:unconvert } // when run against a context, will populate fields like container name @@ -654,7 +654,7 @@ func (suite *syncObjectTestSuite) TestReadRange() { // when run against a context, will populate fields like container name suite.populateDataPlaneInput(&getObjectInput.DataPlaneInput) - response, err := suite.container.GetObjectSync(getObjectInput) + response, err := suite.container.GetObjectSync(getObjectInput) //nolint:ineffassign,staticcheck // SA4006 // get the underlying root error errWithStatusCode, errHasStatusCode := err.(v3ioerrors.ErrorWithStatusCode) @@ -667,7 +667,7 @@ func (suite *syncObjectTestSuite) TestReadRange() { putObjectInput := &v3io.PutObjectInput{ Path: path, - Body: []byte(contents), + Body: []byte(contents), //nolint:unconvert } // when run against a context, will populate fields like container name @@ -801,7 +801,7 @@ func (suite *syncContainerObjectTestSuite) SetupSuite() { type syncKVTestSuite struct { syncTestSuite - items map[string]map[string]interface{} + items map[string]map[string]interface{} //nolint:unused } func (suite *syncKVTestSuite) TestEMD() { @@ -1208,7 +1208,7 @@ func (suite *syncKVTestSuite) verifyItems(items map[string]map[string]interface{ func (suite *syncKVTestSuite) deleteItems(path string, items map[string]map[string]interface{}) { if !strings.HasSuffix(path, "/") { - path = path + "/" + path = path + "/" //nolint:gocritic // assignOp } // delete the items @@ -1226,7 +1226,7 @@ func (suite *syncKVTestSuite) deleteItems(path string, items map[string]map[stri } input := &v3io.DeleteObjectInput{ - Path: fmt.Sprintf("%s", path), + Path: fmt.Sprintf("%s", path), //nolint:staticcheck // S1025 } // when run against a context, will populate fields like container name @@ -1264,12 +1264,12 @@ func (suite *syncContainerKVTestSuite) SetupSuite() { type syncStreamTestSuite struct { syncTestSuite - streamTestSuite streamTestSuite + streamTestSuite streamTestSuite //nolint:govet // copylocks } func (suite *syncStreamTestSuite) SetupTest() { suite.streamTestSuite = streamTestSuite{ - testSuite: suite.syncTestSuite.testSuite, + testSuite: suite.syncTestSuite.testSuite, //nolint:govet,staticcheck // copylocks, QF1008 } suite.streamTestSuite.SetupTest() } @@ -1437,12 +1437,12 @@ func (suite *syncStreamTestSuite) TestStream() { type syncStreamBackupRestoreTestSuite struct { syncTestSuite - streamTestSuite streamTestSuite + streamTestSuite streamTestSuite //nolint:govet // copylocks } func (suite *syncStreamBackupRestoreTestSuite) SetupTest() { suite.streamTestSuite = streamTestSuite{ - testSuite: suite.syncTestSuite.testSuite, + testSuite: suite.syncTestSuite.testSuite, //nolint:govet,staticcheck // copylocks, QF1008 } suite.streamTestSuite.SetupTest() } @@ -1521,10 +1521,10 @@ func (suite *syncStreamBackupRestoreTestSuite) TestStream() { } if chunkMap[chunkId].Metadata != nil { - (*streamBackup[shardName].Chunks[chunkId]).Metadata = chunkMap[chunkId].Metadata + (*streamBackup[shardName].Chunks[chunkId]).Metadata = chunkMap[chunkId].Metadata //nolint:gocritic // underef } if len(chunkMap[chunkId].Data) != 0 { - (*streamBackup[shardName].Chunks[chunkId]).Data = chunkMap[chunkId].Data + (*streamBackup[shardName].Chunks[chunkId]).Data = chunkMap[chunkId].Data //nolint:gocritic // underef } } diff --git a/pkg/dataplane/types.go b/pkg/dataplane/types.go index 97735c7..caa6dd9 100755 --- a/pkg/dataplane/types.go +++ b/pkg/dataplane/types.go @@ -63,7 +63,7 @@ type DataPlaneInput struct { } type DataPlaneOutput struct { - ctx context.Context + ctx context.Context //nolint:unused } // diff --git a/pkg/errors/errors.go b/pkg/errors/errors.go index 48f3339..80b37c4 100644 --- a/pkg/errors/errors.go +++ b/pkg/errors/errors.go @@ -24,10 +24,10 @@ import ( "errors" ) -var ErrInvalidTypeConversion = errors.New("Invalid type conversion") -var ErrNotFound = errors.New("Not found") +var ErrInvalidTypeConversion = errors.New("Invalid type conversion") //nolint:staticcheck // ST1005 +var ErrNotFound = errors.New("Not found") //nolint:staticcheck // ST1005 var ErrStopped = errors.New("Stopped") -var ErrTimeout = errors.New("Timed out") +var ErrTimeout = errors.New("Timed out") //nolint:staticcheck // ST1005 type ErrorWithStatusCode struct { error