feat: support dotenv
This commit is contained in:
parent
d1537fabb5
commit
1c2c242f22
2
go.mod
2
go.mod
@ -22,6 +22,8 @@ require (
|
||||
gorm.io/gorm v1.25.3
|
||||
)
|
||||
|
||||
require github.com/joho/godotenv v1.5.1 // indirect
|
||||
|
||||
require (
|
||||
github.com/bytedance/sonic v1.10.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
|
2
go.sum
2
go.sum
@ -98,6 +98,8 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr
|
||||
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
|
10
main.go
10
main.go
@ -14,6 +14,7 @@ import (
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/sessions/cookie"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
//go:embed web/build
|
||||
@ -23,6 +24,15 @@ var buildFS embed.FS
|
||||
var indexPage []byte
|
||||
|
||||
func main() {
|
||||
// This will load .env file if it exists, to set environment variables instead of exporting them one by one
|
||||
envErr := godotenv.Load()
|
||||
if envErr != nil {
|
||||
common.SysLog("Cannot load .env file, using environment variables, this is not an error, just a reminder")
|
||||
}
|
||||
|
||||
// Sentry is a cross-platform crash reporting and aggregation platform.
|
||||
// It provides the ability to capture, index and store exceptions generated
|
||||
// This will only activate when SENTRY_DSN is set, if you worry about privacy, you can set it to an empty string
|
||||
sentrDSN := os.Getenv("SENTRY_DSN")
|
||||
if sentrDSN != "" {
|
||||
sentry.Init(sentry.ClientOptions{
|
||||
|
Loading…
Reference in New Issue
Block a user