feat: add .env

This commit is contained in:
axolotlmaid 2024-09-25 16:52:29 +01:00
parent f338d86663
commit cb61a2a8b7
2 changed files with 10 additions and 0 deletions

2
.env.example Normal file
View file

@ -0,0 +1,2 @@
# Port for the server
PORT=8888

View file

@ -4,10 +4,18 @@ import (
"log/slog"
"os"
"github.com/joho/godotenv"
"github.com/lmittmann/tint"
)
func main() {
logger := slog.New(tint.NewHandler(os.Stderr, nil))
slog.SetDefault(logger)
err := godotenv.Load()
if err != nil {
slog.Error("Error loading .env file", slog.Any("error", err))
}
slog.Info("Starting server", slog.Any("port", os.Getenv("PORT")))
}