diff --git a/checkenv.go b/checkenv.go index 353bf00..7d80836 100644 --- a/checkenv.go +++ b/checkenv.go @@ -3,11 +3,10 @@ package main import ( "github.com/joho/godotenv" "github.com/thep0y/go-logger/log" - "os" ) func checkDotEnv() bool { - if err := godotenv.Load(os.ExpandEnv("$HOME/.portmonitor/.env")); err != nil { + if err := godotenv.Load(".env"); err != nil { log.Fatal("No .env file found") } diff --git a/helper/database/config.go b/helper/database/config.go index 4122054..c10c420 100644 --- a/helper/database/config.go +++ b/helper/database/config.go @@ -2,7 +2,6 @@ package database import ( "context" - "fmt" "github.com/thep0y/go-logger/log" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" @@ -11,7 +10,6 @@ import ( func IsConnected(URI string) *mongo.Client { client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(URI)) if err != nil { - fmt.Println(URI) log.Fatal("Could not connect to database.") } diff --git a/main.go b/main.go index 793872f..b5db3ab 100644 --- a/main.go +++ b/main.go @@ -9,10 +9,10 @@ import ( ) func main() { + URI := os.Getenv("MONGODB_URI") if checkDotEnv() { log.Fatal("environment file not found") } else { - URI := os.Getenv("MONGODB_URI") defer config.IsConnected(URI).Disconnect(context.TODO()) output.GetOutput() }