Small code cleanup

This commit is contained in:
2024-12-30 20:53:53 +01:00
parent 4d73c122e3
commit b5a1bfc247
3 changed files with 6 additions and 19 deletions

View File

@ -6,9 +6,7 @@ import (
db2 "code.dlmw.ch/dlmw/qv/internal/db"
"code.dlmw.ch/dlmw/qv/internal/models"
"database/sql"
"github.com/go-playground/form/v4"
_ "github.com/mattn/go-sqlite3"
stdlib "github.com/multiprocessio/go-sqlite3-stdlib"
"log/slog"
"net/http"
"os"
@ -16,15 +14,13 @@ import (
)
type application struct {
logger *slog.Logger
elections models.ElectionModelInterface
formDecoder *form.Decoder
logger *slog.Logger
elections models.ElectionModelInterface
}
var addr = ":8080"
func main() {
stdlib.Register("sqlite_math_functions")
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
db, err := openDb()
@ -39,12 +35,9 @@ func main() {
os.Exit(1)
}
formDecoder := form.NewDecoder()
app := &application{
logger: logger,
elections: &models.ElectionModel{DB: db},
formDecoder: formDecoder,
logger: logger,
elections: &models.ElectionModel{DB: db},
}
logger.Info("Starting server", "addr", addr)

View File

@ -2,7 +2,6 @@ package main
import (
"code.dlmw.ch/dlmw/qv/internal/models"
"github.com/go-playground/form/v4"
"io"
"log/slog"
"net/http"
@ -11,12 +10,9 @@ import (
)
func newTestApplication(t *testing.T) *application {
formDecoder := form.NewDecoder()
return &application{
logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
elections: &models.ElectionModel{},
formDecoder: formDecoder,
logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
elections: &models.ElectionModel{},
}
}

2
go.mod
View File

@ -3,11 +3,9 @@ module code.dlmw.ch/dlmw/qv
go 1.23.4
require (
github.com/go-playground/form/v4 v4.2.1
github.com/golang-migrate/migrate/v4 v4.18.1
github.com/justinas/alice v1.2.0
github.com/mattn/go-sqlite3 v1.14.24
github.com/multiprocessio/go-sqlite3-stdlib v0.0.0-20220822170115-9f6825a1cd25
)
require (