package main import ( "context" "database/sql" "fmt" "code.uint32.ru/tiny/repo" _ "github.com/mattn/go-sqlite3" ) type My struct { A string B int } func main() { db, err := sql.Open("sqlite3", "test.db") if err != nil { panic(err) } defer db.Close() ctx := context.Background() // init repository for our type "My" r, err := repo.OpenOrCreate[My](ctx, db, "my_test_table") if err != nil { panic(err) } first := &My{ A: "hello", B: 42, } if err := r.Create(ctx, "first_record", first); err != nil { panic(err) } duplicate, err := r.Read(ctx, "first_record") if err != nil { panic(err) } // prints Type: *main.My, Value: &{A:hello B:42} fmt.Printf("Type: %T, Value: %+v\n", duplicate, duplicate) }