Switch SQLite driver from modernc.org/sqlite to github.com/glebarez/go-sqlite

This commit is contained in:
Trevor Slocum 2024-01-04 11:48:45 -08:00
parent df818c0a17
commit f3b09504ba
12 changed files with 311 additions and 348 deletions

View file

@ -1,4 +1,7 @@
package sriracha
type Account struct {
ID int
Username string
Password string
}

1
board.go Normal file
View file

@ -0,0 +1 @@
package sriracha

View file

@ -2,26 +2,26 @@ package main
import (
"log"
"os"
"code.rocketnine.space/tslocum/sriracha"
"code.rocketnine.space/tslocum/sriracha/extension"
// Load database drivers.
// Load database drivers. SQLite and PostgreSQL are supported by default.
_ "github.com/glebarez/go-sqlite"
_ "github.com/glebarez/go-sqlite/compat"
_ "github.com/lib/pq"
_ "modernc.org/sqlite"
)
func main() {
config.Driver = os.Getenv("SRIRACHA_DRIVER")
config.DataSource = os.Getenv("SRIRACHA_DATASOURCE")
os.Setenv("SRIRACHA_DRIVER", "")
os.Setenv("SRIRACHA_DATASOURCE", "")
// Register extensions.
// Extensions are processed in the order they are added.
// Register database extension.
sqlDatabase, err := extension.DatabaseSQL(config.Driver, config.DataSource)
if err != nil {
log.Fatal(err)
}
sriracha.AddExtension(sqlDatabase)
// Register file attachment extensions.
sriracha.AddExtension(extension.AttachJPG())
@ -29,7 +29,7 @@ func main() {
sriracha.AddExtension(extension.RenderPost())
// Run Sriracha.
err = sriracha.Run()
err := sriracha.Run(config.Driver, config.DataSource)
if err != nil {
log.Fatal(err)
}

246
database.go Normal file
View file

@ -0,0 +1,246 @@
package sriracha
import (
"database/sql"
"reflect"
)
// TODO cache type expansion into name and list of fields and their types
var db *sql.DB
func connectDB(driver string, dataSource string) error {
var err error
db, err = sql.Open(driver, dataSource)
return err
}
func dbCreate[T any](db *sql.DB) error {
var query string
_, err := db.Exec(query)
return err
}
func dbByID[T any](db *sql.DB, table string, id int) (*T, error) {
var columns string
getRow := func() *sql.Row {
return db.QueryRow("SELECT " + columns + " FROM " + table + " WHERE id = ?")
}
var v T
switch node := any(v).(type) {
case *Account:
columns = "id, username, password"
err := getRow().Scan(&node.ID)
if err != nil {
return nil, err
}
}
return &v, nil
}
func StartTransaction() error {
_, err := db.Exec("BEGIN")
return err
}
func CancelTransaction() error {
_, err := db.Exec("ROLLBACK")
return err
}
func CommitTransaction() error {
_, err := db.Exec("COMMIT")
return err
}
func CreateAccount(account *Account) error {
//TODO implement me
panic("implement me")
}
func AccountByID(id int) (*Account, error) {
//TODO implement me
panic("implement me")
}
func AccountByName(name string) (*Account, error) {
//TODO implement me
panic("implement me")
}
func Accounts() ([]*Account, error) {
//TODO implement me
panic("implement me")
}
func UpdateAccount(account *Account) error {
//TODO implement me
panic("implement me")
}
func DeleteAccount(account *Account) error {
//TODO implement me
panic("implement me")
}
func CreateBan(Ban *Ban) error {
//TODO implement me
panic("implement me")
}
func BanByID(id int) (*Ban, error) {
//TODO implement me
panic("implement me")
}
func BanByName(name string) (*Ban, error) {
//TODO implement me
panic("implement me")
}
func Bans() ([]*Ban, error) {
//TODO implement me
panic("implement me")
}
func UpdateBan(Ban *Ban) error {
//TODO implement me
panic("implement me")
}
func DeleteBan(Ban *Ban) error {
//TODO implement me
panic("implement me")
}
func CreateKeyword(Keyword *Keyword) error {
//TODO implement me
panic("implement me")
}
func KeywordByID(id int) (*Keyword, error) {
//TODO implement me
panic("implement me")
}
func KeywordByName(name string) (*Keyword, error) {
//TODO implement me
panic("implement me")
}
func Keywords() ([]*Keyword, error) {
//TODO implement me
panic("implement me")
}
func UpdateKeyword(Keyword *Keyword) error {
//TODO implement me
panic("implement me")
}
func DeleteKeyword(Keyword *Keyword) error {
//TODO implement me
panic("implement me")
}
func CreateLog(Log *Log) error {
//TODO implement me
panic("implement me")
}
func LogByID(id int) (*Log, error) {
//TODO implement me
panic("implement me")
}
func LogByName(name string) (*Log, error) {
//TODO implement me
panic("implement me")
}
func Logs() ([]*Log, error) {
//TODO implement me
panic("implement me")
}
func UpdateLog(Log *Log) error {
//TODO implement me
panic("implement me")
}
func DeleteLog(Log *Log) error {
//TODO implement me
panic("implement me")
}
func CreatePost(Post *Post) error {
//TODO implement me
panic("implement me")
}
func PostByID(id int) (*Post, error) {
//TODO implement me
panic("implement me")
}
func PostByName(name string) (*Post, error) {
//TODO implement me
panic("implement me")
}
func Posts() ([]*Post, error) {
//TODO implement me
panic("implement me")
}
func UpdatePost(Post *Post) error {
//TODO implement me
panic("implement me")
}
func DeletePost(Post *Post) error {
//TODO implement me
panic("implement me")
}
func CreateReport(Report *Report) error {
//TODO implement me
panic("implement me")
}
func ReportByID(id int) (*Report, error) {
//TODO implement me
panic("implement me")
}
func ReportByName(name string) (*Report, error) {
//TODO implement me
panic("implement me")
}
func Reports() ([]*Report, error) {
//TODO implement me
panic("implement me")
}
func UpdateReport(Report *Report) error {
//TODO implement me
panic("implement me")
}
func DeleteReport(Report *Report) error {
//TODO implement me
panic("implement me")
}
func reflectName(v interface{}) string {
sV := reflect.ValueOf(v)
sT := reflect.TypeOf(v)
if sV.Kind() == reflect.Ptr {
sV = sV.Elem()
sT = sT.Elem()
}
return sV.Type().String()
}

View file

@ -9,6 +9,9 @@ import (
type Extension interface {
Description() string
Data() interface{} // TODO reflect to see desired data types and default values
// populate like in gohan
}
var (

View file

@ -7,10 +7,17 @@ import (
"code.rocketnine.space/tslocum/sriracha"
)
type attachJPG struct {
type attachJPGData struct {
Test string
}
var _ sriracha.ExtensionAttach = &attachJPG{}
type attachJPG struct {
data *attachJPGData
}
var _ sriracha.ExtensionAttach = &attachJPG{
data: &attachJPGData{},
}
func AttachJPG() *attachJPG {
return &attachJPG{}
@ -21,6 +28,10 @@ func (a *attachJPG) Description() string {
panic("implement me")
}
func (a *attachJPG) Data() interface{} {
return a.data
}
func (a *attachJPG) Attach(file io.Reader, size int64, mime string) (*sriracha.Attachment, error) {
if mime != "image/jpeg" {
return nil, nil

View file

@ -1,209 +0,0 @@
package extension
import (
"database/sql"
"code.rocketnine.space/tslocum/sriracha"
)
type databaseSQL struct {
db *sql.DB
}
var _ sriracha.ExtensionDatabase = &databaseSQL{}
func DatabaseSQL(driver string, dataSource string) (*databaseSQL, error) {
d := &databaseSQL{}
var err error
d.db, err = sql.Open(driver, dataSource)
if err != nil {
return nil, err
}
return d, nil
}
func (d databaseSQL) Description() string {
return "Official SQL database extension"
}
func (d databaseSQL) CreateAccount(account *sriracha.Account) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) AccountByID(id int) (*sriracha.Account, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) AccountByName(name string) (*sriracha.Account, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) Accounts() ([]*sriracha.Account, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) UpdateAccount(account *sriracha.Account) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) DeleteAccount(account *sriracha.Account) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) CreateBan(Ban *sriracha.Ban) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) BanByID(id int) (*sriracha.Ban, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) BanByName(name string) (*sriracha.Ban, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) Bans() ([]*sriracha.Ban, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) UpdateBan(Ban *sriracha.Ban) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) DeleteBan(Ban *sriracha.Ban) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) CreateKeyword(Keyword *sriracha.Keyword) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) KeywordByID(id int) (*sriracha.Keyword, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) KeywordByName(name string) (*sriracha.Keyword, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) Keywords() ([]*sriracha.Keyword, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) UpdateKeyword(Keyword *sriracha.Keyword) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) DeleteKeyword(Keyword *sriracha.Keyword) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) CreateLog(Log *sriracha.Log) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) LogByID(id int) (*sriracha.Log, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) LogByName(name string) (*sriracha.Log, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) Logs() ([]*sriracha.Log, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) UpdateLog(Log *sriracha.Log) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) DeleteLog(Log *sriracha.Log) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) CreatePost(Post *sriracha.Post) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) PostByID(id int) (*sriracha.Post, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) PostByName(name string) (*sriracha.Post, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) Posts() ([]*sriracha.Post, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) UpdatePost(Post *sriracha.Post) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) DeletePost(Post *sriracha.Post) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) CreateReport(Report *sriracha.Report) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) ReportByID(id int) (*sriracha.Report, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) ReportByName(name string) (*sriracha.Report, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) Reports() ([]*sriracha.Report, error) {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) UpdateReport(Report *sriracha.Report) error {
//TODO implement me
panic("implement me")
}
func (d databaseSQL) DeleteReport(Report *sriracha.Report) error {
//TODO implement me
panic("implement me")
}

View file

@ -24,6 +24,10 @@ func (r *renderPost) Description() string {
panic("implement me")
}
func (r *renderPost) Data() interface{} {
return nil
}
func (r *renderPost) Attach(file io.Reader, size int64, mime string) (*sriracha.Attachment, error) {
return nil, nil
}

View file

@ -1,49 +0,0 @@
package sriracha
// ExtensionDatabase defines the interface for extensions that handle storing and
// retrieving information within a database.
type ExtensionDatabase interface {
Extension
CreateAccount(account *Account) error
AccountByID(id int) (*Account, error)
AccountByName(name string) (*Account, error)
Accounts() ([]*Account, error)
UpdateAccount(account *Account) error
DeleteAccount(account *Account) error
CreateBan(Ban *Ban) error
BanByID(id int) (*Ban, error)
BanByName(name string) (*Ban, error)
Bans() ([]*Ban, error)
UpdateBan(Ban *Ban) error
DeleteBan(Ban *Ban) error
CreateKeyword(Keyword *Keyword) error
KeywordByID(id int) (*Keyword, error)
KeywordByName(name string) (*Keyword, error)
Keywords() ([]*Keyword, error)
UpdateKeyword(Keyword *Keyword) error
DeleteKeyword(Keyword *Keyword) error
CreateLog(Log *Log) error
LogByID(id int) (*Log, error)
LogByName(name string) (*Log, error)
Logs() ([]*Log, error)
UpdateLog(Log *Log) error
DeleteLog(Log *Log) error
CreatePost(Post *Post) error
PostByID(id int) (*Post, error)
PostByName(name string) (*Post, error)
Posts() ([]*Post, error)
UpdatePost(Post *Post) error
DeletePost(Post *Post) error
CreateReport(Report *Report) error
ReportByID(id int) (*Report, error)
ReportByName(name string) (*Report, error)
Reports() ([]*Report, error)
UpdateReport(Report *Report) error
DeleteReport(Report *Report) error
}

25
go.mod
View file

@ -3,27 +3,18 @@ module code.rocketnine.space/tslocum/sriracha
go 1.19
require (
github.com/glebarez/go-sqlite v1.22.0
github.com/lib/pq v1.10.9
modernc.org/sqlite v1.21.2
)
require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
golang.org/x/mod v0.3.0 // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
lukechampine.com/uint128 v1.2.0 // indirect
modernc.org/cc/v3 v3.40.0 // indirect
modernc.org/ccgo/v3 v3.16.13 // indirect
modernc.org/libc v1.22.4 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.5.0 // indirect
modernc.org/opt v0.1.3 // indirect
modernc.org/strutil v1.1.3 // indirect
modernc.org/token v1.0.1 // indirect
golang.org/x/sys v0.16.0 // indirect
modernc.org/libc v1.38.0 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.7.2 // indirect
modernc.org/sqlite v1.28.0 // indirect
)

77
go.sum
View file

@ -1,67 +1,24 @@
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/glebarez/go-sqlite v1.22.0 h1:uAcMJhaA6r3LHMTFgP0SifzgXg46yJkgxqyuyec+ruQ=
github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc=
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78 h1:M8tBwCtWD/cZV9DZpFYRUgaymAYAr+aIUTWzDaM3uPs=
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI=
lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw=
modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0=
modernc.org/ccgo/v3 v3.16.13 h1:Mkgdzl46i5F/CNR/Kj80Ri59hC8TKAhZrYSaqvkwzUw=
modernc.org/ccgo/v3 v3.16.13/go.mod h1:2Quk+5YgpImhPjv2Qsob1DnZ/4som1lJTodubIcoUkY=
modernc.org/ccorpus v1.11.6 h1:J16RXiiqiCgua6+ZvQot4yUuUy8zxgqbqEEUuGPlISk=
modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM=
modernc.org/libc v1.22.4 h1:wymSbZb0AlrjdAVX3cjreCHTPCpPARbQXNz6BHPzdwQ=
modernc.org/libc v1.22.4/go.mod h1:jj+Z7dTNX8fBScMVNRAYZ/jF91K8fdT2hYMThc3YjBY=
modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ=
modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds=
modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/sqlite v1.21.2 h1:ixuUG0QS413Vfzyx6FWx6PYTmHaOegTY+hjzhn7L+a0=
modernc.org/sqlite v1.21.2/go.mod h1:cxbLkB5WS32DnQqeH4h4o1B0eMr8W/y8/RGuxQ3JsC0=
modernc.org/strutil v1.1.3 h1:fNMm+oJklMGYfU9Ylcywl0CO5O6nTfaowNsh2wpPjzY=
modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw=
modernc.org/tcl v1.15.1 h1:mOQwiEK4p7HruMZcwKTZPw/aqtGM4aY00uzWhlKKYws=
modernc.org/token v1.0.1 h1:A3qvTqOwexpfZZeyI0FeGPDlSWX5pjZu9hF4lU+EKWg=
modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
modernc.org/z v1.7.0 h1:xkDw/KepgEjeizO2sNco+hqYkU12taxQFqPEmgm1GWE=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
modernc.org/libc v1.38.0 h1:o4Lpk0zNDSdsjfEXnF1FGXWQ9PDi1NOdWcLP5n13FGo=
modernc.org/libc v1.38.0/go.mod h1:YAXkAZ8ktnkCKaN9sw/UDeUVkGYJ/YquGO4FTi5nmHE=
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E=
modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E=
modernc.org/sqlite v1.28.0 h1:Zx+LyDDmXczNnEQdvPuEfcFVA2ZPyaD7UCZDjef3BHQ=
modernc.org/sqlite v1.28.0/go.mod h1:Qxpazz0zH8Z1xCFyi5GSL3FzbtZ3fvbjmywNogldEW0=

View file

@ -32,7 +32,12 @@ func handleRequest(w http.ResponseWriter, r *http.Request) {
}
}
func Run() error {
func Run(driver string, dataSource string) error {
err := connectDB(driver, dataSource)
if err != nil {
return err
}
http.HandleFunc("/imgboard", handleRequest)
return http.ListenAndServe(":8080", nil)
}