From 08918d37564746037abdbe9d69da3e24a96146c5 Mon Sep 17 00:00:00 2001 From: Vladislav Byrgazov Date: Wed, 13 Nov 2024 16:27:37 +0500 Subject: [PATCH 1/3] Update go to 1.23 Signed-off-by: Vladislav Byrgazov --- .golangci.yml | 20 +++++++------------- go.mod | 2 +- go.sum | 6 ++++++ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index fcdf64e..2cc8847 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,7 @@ --- run: # concurrency: 6 + go: "1.23" timeout: 2m issues-exit-code: 1 tests: true @@ -10,13 +11,14 @@ linters-settings: values: regexp: company: .* - copyright-holder: Copyright \(c\) ({{year-range}}) {{company}}\n\n + copyright-holder: Copyright \(c\) ({{mod-year-range}}) {{company}}\n\n copyright-holders: ({{copyright-holder}})+ errcheck: check-type-assertions: false check-blank: false govet: - check-shadowing: true + enable: + - shadow settings: printf: funcs: @@ -24,12 +26,8 @@ linters-settings: - (github.com/sirupsen/logrus.FieldLogger).Warnf - (github.com/sirupsen/logrus.FieldLogger).Errorf - (github.com/sirupsen/logrus.FieldLogger).Fatalf - golint: - min-confidence: 0.8 gocyclo: min-complexity: 15 - maligned: - suggest-new: true dupl: threshold: 150 funlen: @@ -127,7 +125,6 @@ linters: # - rowserrcheck - goheader - bodyclose - - deadcode - depguard - dogsled - dupl @@ -139,25 +136,22 @@ linters: - gocyclo - gofmt - goimports - - golint - gosec - gosimple - govet - ineffassign - - interfacer # - lll - misspell - nakedret - - scopelint - staticcheck - - structcheck - stylecheck - typecheck - unconvert - unparam - # - unused - - varcheck + - unused - whitespace + - revive + - copyloopvar issues: exclude-use-default: false max-issues-per-linter: 0 diff --git a/go.mod b/go.mod index 2142384..905d5a7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/networkservicemesh/vpphelper -go 1.20 +go 1.23 require ( github.com/edwarnicke/exechelper v1.0.2 diff --git a/go.sum b/go.sum index 38866f7..eea46e6 100644 --- a/go.sum +++ b/go.sum @@ -9,14 +9,17 @@ github.com/edwarnicke/log v1.0.0/go.mod h1:eWsQQlQ0IU5wHlJvyXFH3dS8s2g9GzN7JnXod github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe h1:ewr1srjRCmcQogPQ/NCx6XCk6LGVmsVCc9Y3vvPZj+Y= github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe/go.mod h1:vy1vK6wD6j7xX6O6hXe621WabdtNkou2h7uRtTfRMyg= github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= +github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -33,13 +36,16 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl go.fd.io/govpp v0.10.0-alpha.0.20240110141843-761adec77524 h1:Dja0i7Ln/aUAc10VN4Pp3SibYTfNKS1CPkM5TSGL5jk= go.fd.io/govpp v0.10.0-alpha.0.20240110141843-761adec77524/go.mod h1:9QoqjEbvfuuXNfjHS0A7YS+7QQVVaQ9cMioOWpSM4rY= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 24db0ea12e91ccd1e1ae1b188944e9849ece86d5 Mon Sep 17 00:00:00 2001 From: Vladislav Byrgazov Date: Fri, 15 Nov 2024 11:59:25 +0500 Subject: [PATCH 2/3] Update linter config Signed-off-by: Vladislav Byrgazov --- .golangci.yml | 63 +++++++++++++++++++++------------------------------ connection.go | 2 +- 2 files changed, 27 insertions(+), 38 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 2cc8847..06ccbf2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -26,6 +26,29 @@ linters-settings: - (github.com/sirupsen/logrus.FieldLogger).Warnf - (github.com/sirupsen/logrus.FieldLogger).Errorf - (github.com/sirupsen/logrus.FieldLogger).Fatalf + revive: + confidence: 0.8 + rules: + - name: exported + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: error-return + - name: error-strings + - name: error-naming + - name: exported + - name: increment-decrement + - name: var-naming + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: unexported-return + - name: indent-error-flow + - name: errorf + - name: superfluous-else + - name: unreachable-code gocyclo: min-complexity: 15 dupl: @@ -54,77 +77,45 @@ linters-settings: for-loops: false gocritic: enabled-checks: - - appendAssign - - assignOp - appendCombine - - argOrder - - badCall - - badCond - boolExprSimplify - builtinShadow - - captLocal - - caseOrder - - codegenComment - - commentFormatting - commentedOutCode - commentedOutImport - - defaultCaseOrder - - deprecatedComment - docStub - - dupArg - - dupBranchBody - - dupCase - dupImport - - dupSubExpr - - elseif - emptyFallthrough - emptyStringTest - equalFold - evalOrder - - exitAfterDefer - - flagDeref - - flagName - hexLiteral - hugeParam - - ifElseChain - importShadow - indexAlloc - initClause - methodExprCall - nestingReduce - - newDeref - nilValReturn - octalLiteral - - offBy1 - paramTypeCombine - rangeExprCopy - rangeValCopy - - regexpMust - regexpPattern - - singleCaseSwitch - - sloppyLen - sloppyReassign - stringXbytes - - switchTrue - typeAssertChain - - typeSwitchVar - typeUnparen - unlabelStmt - unnamedResult - unnecessaryBlock - - underef - - unlambda - - unslice - - valSwap - weakCond - - wrapperFunc - yodaStyleExpr linters: disable-all: true enable: - # - rowserrcheck - goheader - bodyclose + - unused - depguard - dogsled - dupl @@ -136,22 +127,20 @@ linters: - gocyclo - gofmt - goimports + - revive - gosec - gosimple - govet - ineffassign - # - lll - misspell - nakedret + - copyloopvar - staticcheck - stylecheck - typecheck - unconvert - unparam - - unused - whitespace - - revive - - copyloopvar issues: exclude-use-default: false max-issues-per-linter: 0 diff --git a/connection.go b/connection.go index 4d2aba2..a9cdf8d 100644 --- a/connection.go +++ b/connection.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. +// Copyright (c) 2020-2024 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // From 341913f28ec02d6262d771c671037dd156be1be8 Mon Sep 17 00:00:00 2001 From: Vladislav Byrgazov Date: Tue, 19 Nov 2024 14:58:18 +0500 Subject: [PATCH 3/3] Use linter config from api Signed-off-by: Vladislav Byrgazov --- .golangci.yml | 28 +++++++++++++++------------- tools_test.go | 1 + 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 06ccbf2..899d603 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -26,6 +26,12 @@ linters-settings: - (github.com/sirupsen/logrus.FieldLogger).Warnf - (github.com/sirupsen/logrus.FieldLogger).Errorf - (github.com/sirupsen/logrus.FieldLogger).Fatalf + depguard: + rules: + main: + deny: + - pkg: "errors" + desc: "Please use \"github.com/pkg/errors\" instead of \"errors\" in go imports" revive: confidence: 0.8 rules: @@ -49,22 +55,17 @@ linters-settings: - name: errorf - name: superfluous-else - name: unreachable-code + goimports: + local-prefixes: github.com/networkservicemesh/vpphelper gocyclo: min-complexity: 15 dupl: threshold: 150 - funlen: - lines: 100 - statements: 50 goconst: min-len: 2 min-occurrences: 2 - depguard: - rules: - main: - deny: - - pkg: "errors" - desc: "Please use \"github.com/pkg/errors\" instead of \"errors\" in go imports" + lll: + line-length: 160 misspell: locale: US unparam: @@ -113,10 +114,11 @@ linters-settings: linters: disable-all: true enable: + - depguard + - revive + - rowserrcheck - goheader - bodyclose - - unused - - depguard - dogsled - dupl - errcheck @@ -127,19 +129,19 @@ linters: - gocyclo - gofmt - goimports - - revive - gosec - gosimple - govet - ineffassign + - lll - misspell - nakedret - - copyloopvar - staticcheck - stylecheck - typecheck - unconvert - unparam + - unused - whitespace issues: exclude-use-default: false diff --git a/tools_test.go b/tools_test.go index 45b25d8..dee5642 100644 --- a/tools_test.go +++ b/tools_test.go @@ -20,6 +20,7 @@ import ( "testing" "github.com/networkservicemesh/vpphelper" + "github.com/stretchr/testify/require" )