Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .circleci/config.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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@v8
with:
version: v2.12.2
2 changes: 1 addition & 1 deletion account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 10 additions & 6 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ import (
"database/sql"
"errors"
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
"sync"

_ "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
Expand Down Expand Up @@ -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)
}
Expand All @@ -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, ";") {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down
Loading