Add location to MySQL connection string

This should address #23
pull/29/head
Matt Baer 6 years ago
parent 9d42d89a27
commit 0eac9251c0
  1. 3
      app.go

@ -8,6 +8,7 @@ import (
"html/template"
"io/ioutil"
"net/http"
"net/url"
"os"
"os/signal"
"regexp"
@ -362,7 +363,7 @@ func Serve() {
func connectToDatabase(app *app) {
log.Info("Connecting to database...")
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=true", app.cfg.Database.User, app.cfg.Database.Password, app.cfg.Database.Host, app.cfg.Database.Port, app.cfg.Database.Database))
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=true&loc=%s", app.cfg.Database.User, app.cfg.Database.Password, app.cfg.Database.Host, app.cfg.Database.Port, app.cfg.Database.Database, url.QueryEscape(time.Local.String())))
if err != nil {
log.Error("%s", err)
os.Exit(1)

Loading…
Cancel
Save