forked from mirror/go-sqlite3
use pointer receiver
This commit is contained in:
parent
fca908b496
commit
a9d61d54c6
|
@ -3,14 +3,15 @@ package main
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/mattn/go-sqlite3"
|
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
|
"github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
sql.Register("sqlite3_with_extensions", &sqlite3.SQLiteDriver{
|
sql.Register("sqlite3_with_extensions", &sqlite3.SQLiteDriver{
|
||||||
ConnectHook: func(conn *sqlite3.SQLiteConn) error {
|
ConnectHook: func(conn *sqlite3.SQLiteConn) error {
|
||||||
return conn.CreateModule("github", githubModule{})
|
return conn.CreateModule("github", &githubModule{})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
db, err := sql.Open("sqlite3_with_extensions", ":memory:")
|
db, err := sql.Open("sqlite3_with_extensions", ":memory:")
|
||||||
|
|
|
@ -19,7 +19,7 @@ type GithubRepo struct {
|
||||||
type githubModule struct {
|
type githubModule struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m githubModule) Create(c *sqlite3.SQLiteConn, args []string) (sqlite3.VTab, error) {
|
func (m *githubModule) Create(c *sqlite3.SQLiteConn, args []string) (sqlite3.VTab, error) {
|
||||||
err := c.DeclareVTab(fmt.Sprintf(`
|
err := c.DeclareVTab(fmt.Sprintf(`
|
||||||
CREATE TABLE %s (
|
CREATE TABLE %s (
|
||||||
id INT,
|
id INT,
|
||||||
|
@ -33,11 +33,11 @@ func (m githubModule) Create(c *sqlite3.SQLiteConn, args []string) (sqlite3.VTab
|
||||||
return &ghRepoTable{}, nil
|
return &ghRepoTable{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m githubModule) Connect(c *sqlite3.SQLiteConn, args []string) (sqlite3.VTab, error) {
|
func (m *githubModule) Connect(c *sqlite3.SQLiteConn, args []string) (sqlite3.VTab, error) {
|
||||||
return m.Create(c, args)
|
return m.Create(c, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m githubModule) DestroyModule() {}
|
func (m *githubModule) DestroyModule() {}
|
||||||
|
|
||||||
type ghRepoTable struct {
|
type ghRepoTable struct {
|
||||||
repos []GithubRepo
|
repos []GithubRepo
|
||||||
|
|
Loading…
Reference in New Issue