mirror of
https://github.com/tiennm99/MTTools.git
synced 2026-08-14 13:23:39 +00:00
Add godotenv dependency and internal/env init loader so all cmd/ scripts get .env vars loaded automatically via blank import.
17 lines
344 B
Go
17 lines
344 B
Go
// Package env loads .env files on init so all cmd/ scripts get env vars automatically.
|
|
// Usage: import _ "github.com/tiennm99/go-util/internal/env"
|
|
package env
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
func init() {
|
|
// Skip if .env doesn't exist; load if it does.
|
|
if _, err := os.Stat(".env"); err == nil {
|
|
_ = godotenv.Load()
|
|
}
|
|
}
|