File tree 3 files changed +12
-1
lines changed
3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ require (
7
7
github.com/gin-gonic/gin v1.7.7
8
8
)
9
9
10
+ require github.com/joho/godotenv v1.5.1 // indirect
11
+
10
12
require (
11
13
github.com/gin-contrib/sse v0.1.0 // indirect
12
14
github.com/go-playground/locales v0.14.0 // indirect
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8
30
30
github.com/google/gofuzz v1.0.0 /go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg =
31
31
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc =
32
32
github.com/gorilla/websocket v1.4.2 /go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE =
33
+ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0 =
34
+ github.com/joho/godotenv v1.5.1 /go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4 =
33
35
github.com/json-iterator/go v1.1.9 /go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4 =
34
36
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM =
35
37
github.com/json-iterator/go v1.1.12 /go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo =
Original file line number Diff line number Diff line change @@ -6,10 +6,17 @@ import (
6
6
"strconv"
7
7
8
8
"github.com/gin-gonic/gin"
9
+ "github.com/joho/godotenv"
9
10
)
10
11
11
12
func main () {
12
- // Get environment variables
13
+ // Load environment variables, one way or another
14
+ err := godotenv .Load ()
15
+ if err != nil {
16
+ fmt .Println ("Couldn't load .env file! Please ensure that you have a .env in this directory. Check main.go for expected variables." )
17
+ return
18
+ }
19
+
13
20
var broker , brokerMissing = os .LookupEnv ("LMI_BROKER" )
14
21
var port , portMissing = os .LookupEnv ("LMI_BROKER_PORT" )
15
22
var portNumber = 1883 // Set a reasonable default.
You can’t perform that action at this time.
0 commit comments