From 3d572f419c54d891fa54fcc06052af1e21750b0d Mon Sep 17 00:00:00 2001 From: jholdstock Date: Fri, 14 Nov 2025 11:27:44 +0000 Subject: [PATCH 1/9] build: Test against Go 1.25. This updates CI to test against Go 1.25 and removes the tests for Go 1.23 accordingly. --- .github/workflows/go.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d6ad4c6..7e8cab2 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: ["1.23", "1.24"] + go: ["1.24", "1.25"] steps: - name: Set up Go uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 #5.3.0 diff --git a/README.md b/README.md index 0424fbe..3b10202 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ changes may be written to a config file in a platform-specific location: ## Build and installation -- **Install Go 1.23 or higher version** +- **Install Go 1.24 or higher version** Installation instructions can be found here: https://golang.org/doc/install. Ensure Go was installed properly and is a supported version: From 891c4fbd91a8b4bea27f016c7169aee8a0098e6e Mon Sep 17 00:00:00 2001 From: jholdstock Date: Fri, 14 Nov 2025 11:28:40 +0000 Subject: [PATCH 2/9] build: Update to latest action versions. This updates to the following Github Actions: - actions/setup-go@4469467 # v6.0.0 - actions/checkout@08c6903 # v5.0.0 --- .github/workflows/go.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 7e8cab2..9d4ecbc 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -12,11 +12,11 @@ jobs: go: ["1.24", "1.25"] steps: - name: Set up Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 #5.3.0 + uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 #6.0.0 with: go-version: ${{ matrix.go }} - name: Check out source - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0 - name: Install linters run: "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.64.5" - name: Build From 7e2fd1ea216cf96149f5a3d38f86d5794d47074d Mon Sep 17 00:00:00 2001 From: jholdstock Date: Fri, 14 Nov 2025 11:42:35 +0000 Subject: [PATCH 3/9] Remove old conditional Go 1.18 code. Since the module requires a minimum of Go 1.23 now, there is no longer any reason to keep the conditional compilation of the func to retrieve VCS commit ID on Go versions prior to 1.18 given it can't build on them anymore anyway. With that in mind, this moves the conditionally-compiled implementation for Go1.18+ into the main file so that it is always compiled as the only implementation and removes the old conditionally-compiled implementation for Go versions prior to 1.18. --- version.go | 28 +++++++++++++++++++++++++++- version_buildinfo.go | 35 ----------------------------------- version_nobuildinfo.go | 14 -------------- 3 files changed, 27 insertions(+), 50 deletions(-) delete mode 100644 version_buildinfo.go delete mode 100644 version_nobuildinfo.go diff --git a/version.go b/version.go index 69e7912..0efe6be 100644 --- a/version.go +++ b/version.go @@ -1,5 +1,5 @@ // Copyright (c) 2013-2014 The btcsuite developers -// Copyright (c) 2015-2022 The Decred developers +// Copyright (c) 2015-2025 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -8,6 +8,7 @@ package main import ( "fmt" "regexp" + "runtime/debug" "strconv" "strings" ) @@ -129,6 +130,31 @@ func parseSemVer(s string) (uint32, uint32, uint32, string, string, error) { return major, minor, patch, preRel, build, nil } +// vcsCommitID attempts to return the version control system short commit hash +// that was used to build the binary. It currently only detects git commits. +func vcsCommitID() string { + bi, ok := debug.ReadBuildInfo() + if !ok { + return "" + } + var vcs, revision string + for _, bs := range bi.Settings { + switch bs.Key { + case "vcs": + vcs = bs.Value + case "vcs.revision": + revision = bs.Value + } + } + if vcs == "" { + return "" + } + if vcs == "git" && len(revision) > 9 { + revision = revision[:9] + } + return revision +} + func init() { var err error Major, Minor, Patch, PreRelease, BuildMetadata, err = parseSemVer(Version) diff --git a/version_buildinfo.go b/version_buildinfo.go deleted file mode 100644 index 30032e3..0000000 --- a/version_buildinfo.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2021-2022 The Decred developers -// Use of this source code is governed by an ISC -// license that can be found in the LICENSE file. - -//go:build go1.18 -// +build go1.18 - -package main - -import "runtime/debug" - -// vcsCommitID attempts to return the version control system short commit hash -// that was used to build the binary. It currently only detects git commits. -func vcsCommitID() string { - bi, ok := debug.ReadBuildInfo() - if !ok { - return "" - } - var vcs, revision string - for _, bs := range bi.Settings { - switch bs.Key { - case "vcs": - vcs = bs.Value - case "vcs.revision": - revision = bs.Value - } - } - if vcs == "" { - return "" - } - if vcs == "git" && len(revision) > 9 { - revision = revision[:9] - } - return revision -} diff --git a/version_nobuildinfo.go b/version_nobuildinfo.go deleted file mode 100644 index ae27b13..0000000 --- a/version_nobuildinfo.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2021-2022 The Decred developers -// Use of this source code is governed by an ISC -// license that can be found in the LICENSE file. - -//go:build !go1.18 -// +build !go1.18 - -package main - -// vcsCommitID returns an empty string for all Go versions prior to 1.18 since -// the information is not availalbe in binaries prior to that version. -func vcsCommitID() string { - return "" -} From 280c43c6012546d357cce14ebc055f659ca78dfd Mon Sep 17 00:00:00 2001 From: jholdstock Date: Fri, 14 Nov 2025 11:53:51 +0000 Subject: [PATCH 4/9] Update license to 2025. --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 34133ee..ef7f2ff 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2013-2017 The btcsuite developers -Copyright (c) 2015-2020 The Decred developers +Copyright (c) 2015-2025 The Decred developers Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above From eca4b1c13e30d95b0a01d4d8d860a42ab5e2c26a Mon Sep 17 00:00:00 2001 From: jholdstock Date: Fri, 14 Nov 2025 13:15:50 +0000 Subject: [PATCH 5/9] build: Update golangci-lint to v2.6.1 Various changes in this new major version, including a new config file format: - "gofmt" and "goimports" are now categorized as formatters (instead of linters) and are moved to their own section. - The functionality of "gosimple" has been bundled into "staticcheck". Only the "gosimple" behaviour is enabled (prefix "S1") and all other "staticcheck" behaviour is disabled. - "typecheck" is now always on and cannot be independently enabled/disabled. --- .github/workflows/go.yml | 2 +- .golangci.yml | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 9d4ecbc..24e9903 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -18,7 +18,7 @@ jobs: - name: Check out source uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0 - name: Install linters - run: "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.64.5" + run: "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.6.1" - name: Build run: go build ./... - name: Lint diff --git a/.golangci.yml b/.golangci.yml index 8ec3b42..899d45a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,17 +1,14 @@ +version: "2" run: - deadline: 10m - + timeout: 10m linters: - disable-all: true + default: none enable: - asciicheck - bidichk - bodyclose - durationcheck - errchkjson - - gofmt - - goimports - - gosimple - govet - grouper - ineffassign @@ -19,8 +16,16 @@ linters: - nosprintfhostport - reassign - rowserrcheck + - staticcheck - tparallel - - typecheck - unconvert - unused - usetesting + settings: + staticcheck: + checks: + - S1* +formatters: + enable: + - gofmt + - goimports From 6ac077a130bd6adbd0cd2b37700cd864a2f786ba Mon Sep 17 00:00:00 2001 From: jholdstock Date: Fri, 14 Nov 2025 13:02:53 +0000 Subject: [PATCH 6/9] build: Enable dupword linter. Includes source changes to make linter pass. --- .golangci.yml | 1 + dcrctl.go | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 899d45a..d3f208f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -7,6 +7,7 @@ linters: - asciicheck - bidichk - bodyclose + - dupword - durationcheck - errchkjson - govet diff --git a/dcrctl.go b/dcrctl.go index f07e875..f5c8537 100644 --- a/dcrctl.go +++ b/dcrctl.go @@ -1,5 +1,5 @@ // Copyright (c) 2013-2015 The btcsuite developers -// Copyright (c) 2015-2023 The Decred developers +// Copyright (c) 2015-2025 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -40,9 +40,9 @@ func commandUsage(method interface{}) { fmt.Fprintf(os.Stderr, " %s\n", usage) } -// usage displays the general usage when the help flag is not displayed and -// and an invalid command was specified. The commandUsage function is used -// instead when a valid command was specified. +// usage displays the general usage when the help flag is not displayed and an +// invalid command was specified. The commandUsage function is used instead +// when a valid command was specified. func usage(errorMessage string) { appName := filepath.Base(os.Args[0]) appName = strings.TrimSuffix(appName, filepath.Ext(appName)) From 3fd477a185a64d1f8403c2ea9f470a2b0a356699 Mon Sep 17 00:00:00 2001 From: jholdstock Date: Fri, 14 Nov 2025 13:05:37 +0000 Subject: [PATCH 7/9] build: Enable errorlint linter. Includes source changes to make linter pass. --- .golangci.yml | 1 + httpclient.go | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index d3f208f..b6912e4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,6 +10,7 @@ linters: - dupword - durationcheck - errchkjson + - errorlint - govet - grouper - ineffassign diff --git a/httpclient.go b/httpclient.go index 4a85978..e44c5fa 100644 --- a/httpclient.go +++ b/httpclient.go @@ -1,5 +1,5 @@ // Copyright (c) 2013-2015 The btcsuite developers -// Copyright (c) 2015-2023 The Decred developers +// Copyright (c) 2015-2025 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -58,7 +58,7 @@ func newHTTPClient(cfg *config) (*http.Client, error) { } keypair, err := tls.LoadX509KeyPair(cfg.ClientCert, cfg.ClientKey) if err != nil { - return nil, fmt.Errorf("read client keypair: %v", err) + return nil, fmt.Errorf("read client keypair: %w", err) } tlsConfig.Certificates = []tls.Certificate{keypair} @@ -73,7 +73,7 @@ func newHTTPClient(cfg *config) (*http.Client, error) { pool := x509.NewCertPool() if ok := pool.AppendCertsFromPEM(pem); !ok { - return nil, fmt.Errorf("invalid certificate file: %v", + return nil, fmt.Errorf("invalid certificate file: %s", cfg.RPCCert) } tlsConfig.RootCAs = pool From 651408e0d45b248834ed05c841d72c90c409864a Mon Sep 17 00:00:00 2001 From: jholdstock Date: Fri, 14 Nov 2025 13:09:19 +0000 Subject: [PATCH 8/9] build: Enable usestdlibvars linter. Includes source changes to make linter pass. --- .golangci.yml | 1 + httpclient.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index b6912e4..58e218d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -22,6 +22,7 @@ linters: - tparallel - unconvert - unused + - usestdlibvars - usetesting settings: staticcheck: diff --git a/httpclient.go b/httpclient.go index e44c5fa..0e54a5f 100644 --- a/httpclient.go +++ b/httpclient.go @@ -106,7 +106,7 @@ func sendPostRequest(marshalledJSON []byte, cfg *config) ([]byte, error) { fmt.Println(string(marshalledJSON)) } bodyReader := bytes.NewReader(marshalledJSON) - httpRequest, err := http.NewRequest("POST", url, bodyReader) + httpRequest, err := http.NewRequest(http.MethodPost, url, bodyReader) if err != nil { return nil, err } From a00d7e5db885bdc20978976e066599fb8aea2fdb Mon Sep 17 00:00:00 2001 From: jholdstock Date: Fri, 14 Nov 2025 13:09:40 +0000 Subject: [PATCH 9/9] build: Enable more linters. --- .golangci.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 58e218d..9825d98 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -7,20 +7,33 @@ linters: - asciicheck - bidichk - bodyclose + - containedctx + - copyloopvar - dupword - durationcheck - errchkjson - errorlint + - exhaustive + - fatcontext + - goconst + - godot - govet - grouper - ineffassign + - makezero + - mirror - misspell + - nilerr + - nilnil - nosprintfhostport + - prealloc + - predeclared - reassign - rowserrcheck - staticcheck - tparallel - unconvert + - unparam - unused - usestdlibvars - usetesting