Browse Source

add flag for godotenv

pull/1/head
Stephanie Gredell 7 months ago
parent
commit
8bc52fd5f0
  1. 10
      cmd/systemdesigngame/main.go

10
cmd/systemdesigngame/main.go

@ -1,6 +1,7 @@
package main package main
import ( import (
"flag"
"github.com/joho/godotenv" "github.com/joho/godotenv"
"html/template" "html/template"
"net/http" "net/http"
@ -11,11 +12,16 @@ import (
) )
func main() { func main() {
err := godotenv.Load() devMode := flag.Bool("dev", false, "load .env (local dev)")
if err != nil { flag.Parse()
if *devMode {
if err := godotenv.Load(); err != nil {
panic("failed to load .env") panic("failed to load .env")
} }
}
// set up JWT secret used for authentication // set up JWT secret used for authentication
auth.JwtSecret = []byte(os.Getenv("JWT_SECRET")) auth.JwtSecret = []byte(os.Getenv("JWT_SECRET"))
tmpl := template.Must(template.ParseGlob("static/*.html")) tmpl := template.Must(template.ParseGlob("static/*.html"))

Loading…
Cancel
Save