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
26 changes: 17 additions & 9 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,41 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version: 1.17
go-version: 1.24 # TODO: matrix

- name: build
- name: Build
run: go build -v ./...

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version: 1.17
go-version: 1.24 # TODO: matrix

- name: Test
run: go test -v -race ./...

check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: golangci-lint
run: docker run -v $GITHUB_WORKSPACE:/repo -w /repo golangci/golangci-lint:v1.42 golangci-lint run
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
with:
version: v2.5.0

- name: Run linter
uses: magefile/mage-action@6f50bbb8ea47d56e62dee92392788acbc8192d0b # v3.1.0
with:
version: latest
args: lint
10 changes: 7 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
issues:
exclude:
- "SA1019: .* has been deprecated since Go 1.*: Drivers should implement .*"
version: "2"
linters:
exclusions:
rules:
- linters:
- staticcheck
text: "SA1019: .* has been deprecated since Go 1.*: Drivers should implement .*" # TODO: upgrade Go version, and drop these functions?
7 changes: 7 additions & 0 deletions .tools/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module tools

go 1.24.0

tool github.com/magefile/mage

require github.com/magefile/mage v1.15.0 // indirect
2 changes: 2 additions & 0 deletions .tools/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[![GoDoc](https://godoc.org/github.com/ngrok/sqlmw?status.svg)](https://godoc.org/github.com/ngrok/sqlmw)
[![docs](https://pkg.go.dev/badge/github.com/ngrok/sqlmw?status.svg)](https://pkg.go.dev/github.com/ngrok/sqlmw)

# sqlmw

sqlmw provides an absurdly simple API that allows a caller to wrap a `database/sql` driver
with middleware.

Expand Down
4 changes: 2 additions & 2 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (c wrappedParentConn) BeginTx(ctx context.Context, opts driver.TxOptions) (
case <-ctx.Done():
return nil, ctx.Err()
default:
return c.Conn.Begin()
return c.Begin()
}
}

Expand All @@ -142,7 +142,7 @@ func (c wrappedParentConn) PrepareContext(ctx context.Context, query string) (dr
case <-ctx.Done():
return nil, ctx.Err()
default:
return c.Conn.Prepare(query)
return c.Prepare(query)
}
}

Expand Down
4 changes: 2 additions & 2 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestConnQueryContext_PassWrappedRowContext(t *testing.T) {
}

rows.Next()
rows.Close()
_ = rows.Close()

if !ti.RowsCloseValid {
t.Error("RowsClose context not valid")
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestConnPrepareContext_PassWrappedStmtContext(t *testing.T) {
t.Fatalf("Prepare failed: %s", err)
}

stmt.Close()
_ = stmt.Close()

if !ti.StmtCloseValid {
t.Error("StmtClose context not valid")
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/ngrok/sqlmw

go 1.13

require github.com/magefile/mage v1.15.0
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
16 changes: 16 additions & 0 deletions magefiles/mage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:build mage

package main

import (
"context"

"github.com/magefile/mage/sh"
)

// Lint runs the linter
func Lint(ctx context.Context) error {
//args := []string{"tool", "-modfile=./.tools/go.mod", "github.com/golangci/golangci-lint/v2/cmd/golangci-lint", "run", "--config", ".golangci.yml"}
args := []string{"run", "--config", ".golangci.yml"}
return sh.RunV("golangci-lint", args...)
}
4 changes: 2 additions & 2 deletions stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (s wrappedParentStmt) QueryContext(ctx context.Context, args []driver.Named
case <-ctx.Done():
return nil, ctx.Err()
}
return s.Stmt.Query(dargs)
return s.Query(dargs)
}

func (s wrappedParentStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (res driver.Result, err error) {
Expand All @@ -106,5 +106,5 @@ func (s wrappedParentStmt) ExecContext(ctx context.Context, args []driver.NamedV
case <-ctx.Done():
return nil, ctx.Err()
}
return s.Stmt.Exec(dargs)
return s.Exec(dargs)
}
4 changes: 2 additions & 2 deletions stmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func TestStmtQueryContext_PassWrappedRowContext(t *testing.T) {
}

rows.Next()
rows.Close()
stmt.Close()
_ = rows.Close()
_ = stmt.Close()

if !ti.RowsNextValid {
t.Error("RowsNext context not valid")
Expand Down