Skip to content

Commit

Permalink
fixed environment location to ~/.portmonitor/.env
Browse files Browse the repository at this point in the history
  • Loading branch information
rudSarkar committed Aug 21, 2022
1 parent b2a50d2 commit f492dac
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
3 changes: 1 addition & 2 deletions checkenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
2 changes: 0 additions & 2 deletions helper/database/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.")
}

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit f492dac

Please sign in to comment.