counter add anotations

This commit is contained in:
speatzle 2024-05-10 18:00:07 +02:00
parent d612ce68c4
commit 13433c2972
2 changed files with 24 additions and 2 deletions

View file

@ -9,6 +9,7 @@ import (
"net/http"
"os"
"os/signal"
"strconv"
"time"
"github.com/golang-migrate/migrate/v4"
@ -23,6 +24,14 @@ var conf config.Config
var templates *template.Template
var funcMap = template.FuncMap{
"sub": sub,
}
func sub(a, b int64) string {
return strconv.FormatInt(a-b, 10)
}
var db *pgxpool.Pool
func Start(_conf config.Config, tmplFS embed.FS, staticFS embed.FS, migrationsFS embed.FS) {
@ -33,7 +42,9 @@ func Start(_conf config.Config, tmplFS embed.FS, staticFS embed.FS, migrationsFS
fs := http.FileServer(staticServer)
// Templates
t, err := template.ParseFS(tmplFS, "tmpl/*.tmpl")
t := template.New("")
t.Funcs(funcMap)
t, err := t.ParseFS(tmplFS, "tmpl/*.tmpl")
if err != nil {
panic(fmt.Errorf("Parsing templates: %w", err))
}