feat!: run checks on env variables
This commit is contained in:
parent
d664899ab6
commit
d76aa4ca11
16
env/checks.go
vendored
Normal file
16
env/checks.go
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package env
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RunChecks() {
|
||||||
|
checkEnv("APP_URL")
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkEnv(key string) {
|
||||||
|
if os.Getenv(key) == "" {
|
||||||
|
panic(fmt.Sprintf("Environment variable %s is not set", key))
|
||||||
|
}
|
||||||
|
}
|
3
main.go
3
main.go
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"anonymousoverflow/env"
|
||||||
"anonymousoverflow/src/middleware"
|
"anonymousoverflow/src/middleware"
|
||||||
"anonymousoverflow/src/routes"
|
"anonymousoverflow/src/routes"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -11,6 +12,8 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
|
env.RunChecks()
|
||||||
|
|
||||||
host := os.Getenv("HOST")
|
host := os.Getenv("HOST")
|
||||||
if host == "" {
|
if host == "" {
|
||||||
host = "0.0.0.0"
|
host = "0.0.0.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user