From c1fd7ce85bfc4be04582d0bc60740c402f73ce5d Mon Sep 17 00:00:00 2001 From: Riccardo Perotti Date: Mon, 8 Jun 2026 11:53:47 -0400 Subject: [PATCH 1/3] Install golangci-lint (GitHub Actions) and fix lint issues Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/build.yml | 12 ++++++++++++ account.go | 2 +- common.go | 16 ++++++++++------ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a88ed6e..afad3b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,3 +17,15 @@ jobs: run: go vet ./... - name: Test run: go test ./... + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.26' + - name: Lint + uses: golangci/golangci-lint-action@v6 + with: + version: latest diff --git a/account.go b/account.go index f46b7e3..c3d1e0d 100644 --- a/account.go +++ b/account.go @@ -118,7 +118,7 @@ func (a *Account) DB() (*sql.DB, error) { } func (a *Account) QueryPrep(query string) string { - return strings.Replace(strings.Replace(query, "{config}", a.config.dbname, -1), "{ops}", a.ops.dbname, -1) + return strings.ReplaceAll(strings.ReplaceAll(query, "{config}", a.config.dbname), "{ops}", a.ops.dbname) } func (a *Account) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) { diff --git a/common.go b/common.go index 4e70511..01741b2 100644 --- a/common.go +++ b/common.go @@ -5,7 +5,7 @@ import ( "database/sql" "errors" "fmt" - "io/ioutil" + "os" "strconv" "strings" "sync" @@ -13,7 +13,11 @@ import ( _ "github.com/go-sql-driver/mysql" ) -var RestrictedReadAccounts = fmt.Errorf("common database config does not allow reading accounts") +// RestrictedReadAccounts is part of the public API; renaming to the ErrFoo +// convention would be a breaking change for consumers, so ST1012 is suppressed. +// +//nolint:staticcheck // ST1012: exported identifier kept stable for API compatibility +var RestrictedReadAccounts = errors.New("common database config does not allow reading accounts") type Common struct { config OpenConfig @@ -51,7 +55,7 @@ func DefaultOpenConfig() OpenConfig { } func Open(ctx context.Context, config OpenConfig) (*Common, error) { - conftext, err := ioutil.ReadFile(config.ConfigPath) + conftext, err := os.ReadFile(config.ConfigPath) if err != nil { return nil, fmt.Errorf("cannot read %s: %s", config.ConfigPath, err) } @@ -70,7 +74,7 @@ func Open(ctx context.Context, config OpenConfig) (*Common, error) { for _, line := range strings.Split(string(conftext), "\n") { nocomment := strings.TrimSpace(strings.Split(line, "#")[0]) if strings.HasPrefix(nocomment, "---") { - return nil, errors.New("Multi-section DBR configs not supported") + return nil, errors.New("multi-section DBR configs not supported") } for _, part := range strings.Split(nocomment, ";") { @@ -121,7 +125,7 @@ func Open(ctx context.Context, config OpenConfig) (*Common, error) { } func ReadGtutilConfig(filename string) (map[string]string, error) { - text, err := ioutil.ReadFile(filename) + text, err := os.ReadFile(filename) if err != nil { return nil, fmt.Errorf("cannot read %s: %s", filename, err) } @@ -187,7 +191,7 @@ func (p *Common) OpenInstance(i *DbrInstance) (*sql.DB, error) { defer p.accountDBLock.Unlock() if p.closing { - return nil, errors.New("Pool being closed") + return nil, errors.New("pool being closed") } if db := p.accountDB[dsn]; db != nil { From 8f75ccaae54996ebdacb65f5d188e2b7c4b80338 Mon Sep 17 00:00:00 2001 From: Riccardo Perotti Date: Mon, 8 Jun 2026 12:20:17 -0400 Subject: [PATCH 2/3] Use golangci-lint-action@v8 (v2.12.2) for go1.26 Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index afad3b4..f7c3798 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,6 +26,6 @@ jobs: with: go-version: '1.26' - name: Lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v8 with: - version: latest + version: v2.12.2 From 78ca1cdb9c3ec098fc5fa0d35ac4ab1dcc583872 Mon Sep 17 00:00:00 2001 From: Riccardo Perotti Date: Mon, 8 Jun 2026 12:28:04 -0400 Subject: [PATCH 3/3] Remove dead CircleCI config (migrated to GitHub Actions) Co-Authored-By: Claude Opus 4.8 (1M context) --- .circleci/config.yml | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 27675f5..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: 2 - -jobs: - build: - working_directory: /go/src/github.com/gudtech/dbr-go - docker: - - image: circleci/golang:1.10.3 - steps: - - checkout - - run: dep ensure -vendor-only - - run: go test -v -race ./...