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
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# dbtyp

[![CI](https://github.com/winebarrel/dbtyp/actions/workflows/ci.yml/badge.svg)](https://github.com/winebarrel/dbtyp/actions/workflows/ci.yml)
[![Go Reference](https://pkg.go.dev/badge/github.com/winebarrel/dbtyp.svg)](https://pkg.go.dev/github.com/winebarrel/dbtyp)
[![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/winebarrel/dbtyp)](https://pkg.go.dev/github.com/winebarrel/dbtyp?tab=versions)
[![Go Report Card](https://goreportcard.com/badge/github.com/winebarrel/dbtyp)](https://goreportcard.com/report/github.com/winebarrel/dbtyp)
[![CI](https://github.com/kanmu/dbtyp/actions/workflows/ci.yml/badge.svg)](https://github.com/kanmu/dbtyp/actions/workflows/ci.yml)
[![Go Reference](https://pkg.go.dev/badge/github.com/kanmu/dbtyp.svg)](https://pkg.go.dev/github.com/kanmu/dbtyp)
[![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/kanmu/dbtyp)](https://pkg.go.dev/github.com/kanmu/dbtyp?tab=versions)
[![Go Report Card](https://goreportcard.com/badge/github.com/kanmu/dbtyp)](https://goreportcard.com/report/github.com/kanmu/dbtyp)

dbtyp is a library that associates types with `*sql.DB`.

[*dbtyp.DB[T]](https://pkg.go.dev/github.com/winebarrel/dbtyp#DB) and [*dbtyp.Tx[T]](https://pkg.go.dev/github.com/winebarrel/dbtyp#Tx) have the same methods as [*sql.DB](https://pkg.go.dev/database/sql#DB) and [*sql.Tx](https://pkg.go.dev/database/sql#Tx), but it can define different types with the same interface using [generics](https://go.dev/doc/tutorial/generics).
[*dbtyp.DB[T]](https://pkg.go.dev/github.com/kanmu/dbtyp#DB) and [*dbtyp.Tx[T]](https://pkg.go.dev/github.com/kanmu/dbtyp#Tx) have the same methods as [*sql.DB](https://pkg.go.dev/database/sql#DB) and [*sql.Tx](https://pkg.go.dev/database/sql#Tx), but it can define different types with the same interface using [generics](https://go.dev/doc/tutorial/generics).

Additionally, it can generate instances of restricted types [*dbtyp.ExecQueryer[T]](https://pkg.go.dev/github.com/winebarrel/dbtyp#ExecQueryer), [*dbtyp.Execer[T]](https://pkg.go.dev/github.com/winebarrel/dbtyp#Execer), and [*dbtyp.Queryer[T]](https://pkg.go.dev/github.com/winebarrel/dbtyp#Queryer).
Additionally, it can generate instances of restricted types [*dbtyp.ExecQueryer[T]](https://pkg.go.dev/github.com/kanmu/dbtyp#ExecQueryer), [*dbtyp.Execer[T]](https://pkg.go.dev/github.com/kanmu/dbtyp#Execer), and [*dbtyp.Queryer[T]](https://pkg.go.dev/github.com/kanmu/dbtyp#Queryer).

## Installation

```sh
go get github.com/winebarrel/dbtyp
go get github.com/kanmu/dbtyp
```

## Usage
Expand All @@ -26,7 +26,7 @@ import (
"database/sql"
"fmt"

"github.com/winebarrel/dbtyp"
"github.com/kanmu/dbtyp"
_ "modernc.org/sqlite"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"database/sql"
"fmt"

"github.com/winebarrel/dbtyp"
"github.com/kanmu/dbtyp"
_ "modernc.org/sqlite"
)

Expand Down
2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"database/sql"

"github.com/winebarrel/dbtyp/iface"
"github.com/kanmu/dbtyp/iface"
)

type DB[T any] struct {
Expand Down
2 changes: 1 addition & 1 deletion dbtyp.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dbtyp

import (
"github.com/winebarrel/dbtyp/iface"
"github.com/kanmu/dbtyp/iface"
)

func New[T any](v iface.DB) *DB[T] {
Expand Down
4 changes: 2 additions & 2 deletions dbtyp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/winebarrel/dbtyp"
"github.com/winebarrel/dbtyp/iface"
"github.com/kanmu/dbtyp"
"github.com/kanmu/dbtyp/iface"
_ "modernc.org/sqlite"
)

Expand Down
2 changes: 1 addition & 1 deletion exec_queryer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"database/sql"

"github.com/winebarrel/dbtyp/iface"
"github.com/kanmu/dbtyp/iface"
)

var _ iface.ExecQueryer = &ExecQueryer[struct{}]{}
Expand Down
2 changes: 1 addition & 1 deletion execer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"database/sql"

"github.com/winebarrel/dbtyp/iface"
"github.com/kanmu/dbtyp/iface"
)

var _ iface.Execer = &Execer[struct{}]{}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/winebarrel/dbtyp
module github.com/kanmu/dbtyp

go 1.24.0

Expand Down
4 changes: 2 additions & 2 deletions prepare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/winebarrel/dbtyp"
"github.com/winebarrel/dbtyp/iface"
"github.com/kanmu/dbtyp"
"github.com/kanmu/dbtyp/iface"
_ "modernc.org/sqlite"
)

Expand Down
2 changes: 1 addition & 1 deletion queryer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"database/sql"

"github.com/winebarrel/dbtyp/iface"
"github.com/kanmu/dbtyp/iface"
)

var _ iface.Queryer = &Queryer[struct{}]{}
Expand Down
2 changes: 1 addition & 1 deletion stmt.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dbtyp

import (
"github.com/winebarrel/dbtyp/iface"
"github.com/kanmu/dbtyp/iface"
)

type Stmt[T any] struct {
Expand Down
2 changes: 1 addition & 1 deletion tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dbtyp
import (
"context"

"github.com/winebarrel/dbtyp/iface"
"github.com/kanmu/dbtyp/iface"
)

type Tx[T any] struct {
Expand Down
4 changes: 2 additions & 2 deletions tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/winebarrel/dbtyp"
"github.com/winebarrel/dbtyp/iface"
"github.com/kanmu/dbtyp"
"github.com/kanmu/dbtyp/iface"
_ "modernc.org/sqlite"
)

Expand Down
Loading