diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d6ad4c6..24e9903 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -9,16 +9,16 @@ 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 + 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" + 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..9825d98 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,26 +1,47 @@ +version: "2" run: - deadline: 10m - + timeout: 10m linters: - disable-all: true + default: none enable: - asciicheck - bidichk - bodyclose + - containedctx + - copyloopvar + - dupword - durationcheck - errchkjson - - gofmt - - goimports - - gosimple + - errorlint + - exhaustive + - fatcontext + - goconst + - godot - govet - grouper - ineffassign + - makezero + - mirror - misspell + - nilerr + - nilnil - nosprintfhostport + - prealloc + - predeclared - reassign - rowserrcheck + - staticcheck - tparallel - - typecheck - unconvert + - unparam - unused + - usestdlibvars - usetesting + settings: + staticcheck: + checks: + - S1* +formatters: + enable: + - gofmt + - goimports 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 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: 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)) diff --git a/httpclient.go b/httpclient.go index 4a85978..0e54a5f 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 @@ -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 } 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 "" -}