From c579b125381fbd51b6534beea04b76d82dd7909b Mon Sep 17 00:00:00 2001 From: Dylan <64976002+galt-tr@users.noreply.github.com> Date: Mon, 21 Oct 2024 22:21:50 -0400 Subject: [PATCH] Move to go 1.23 and fix CI (#147) * Move to go 1.23 * Update golangci-lint * Fix linting --- .github/workflows/run-tests.yml | 2 +- .golangci.yml | 4 ++++ .make/go.mk | 2 +- app/p2p/server.go | 19 +------------------ 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ba1b86e..b4198c9 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -41,7 +41,7 @@ jobs: needs: [yamllint] strategy: matrix: - go-version: [1.22.x] + go-version: [1.23.x] os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: diff --git a/.golangci.yml b/.golangci.yml index aef875f..67902ae 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -93,6 +93,9 @@ linters-settings: gocognit: # minimal code complexity to report, 30 by default (but we recommend 10-20) min-complexity: 10 + gosec: + excludes: + - G115 nestif: # minimal complexity of if statements to report, 5 by default min-complexity: 4 @@ -383,6 +386,7 @@ issues: - path: _test\.go linters: - gocyclo + - testifylint # Exclude known linters from partially hard-vendored code, # which is impossible to exclude via "nolint" comments. diff --git a/.make/go.mk b/.make/go.mk index e953761..db010ae 100644 --- a/.make/go.mk +++ b/.make/go.mk @@ -78,7 +78,7 @@ lint: ## Run the golangci-lint application (install if not found) GOPATH=$$(go env GOPATH); \ if [ -z "$$GOPATH" ]; then GOPATH=$$HOME/go; fi; \ echo "Installation path: $$GOPATH/bin"; \ - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$GOPATH/bin v1.59.1; \ + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$GOPATH/bin v1.61.0; \ fi; \ fi; \ if [ "$(TRAVIS)" != "" ]; then \ diff --git a/app/p2p/server.go b/app/p2p/server.go index 804f786..4e0f9da 100644 --- a/app/p2p/server.go +++ b/app/p2p/server.go @@ -491,27 +491,10 @@ func generatePrivateKey(filePath string) (*crypto.PrivKey, error) { return &privateKey, nil } -// readPrivateKeyFromFile reads a private key from `private_key_path` file -func readPrivateKeyFromFile(filePath string) (*crypto.PrivKey, error) { - // Read private key from a file - privateBytes, err := os.ReadFile(filePath) //nolint:gosec // This is a local private key - if err != nil { - return nil, err - } - - // Unmarshal the private key bytes into a key - var privateKey crypto.PrivKey - if privateKey, err = crypto.UnmarshalPrivateKey(privateBytes); err != nil { - return nil, err - } - - return &privateKey, nil -} - // readPrivateKey reads a private key from `private_key` hex encoded string func readPrivateKey(privKeyHex string) (*crypto.PrivKey, error) { // Read private key from a file - privateBytes, err := hex.DecodeString(privKeyHex) //nolint:gosec // This is a local private key + privateBytes, err := hex.DecodeString(privKeyHex) if err != nil { return nil, err }