Compare commits

..

No commits in common. "1b83793f3852a4afa70163bd3948ece17df0afed" and "4877f72f043cf7c910b969ea39226b8535a8d342" have entirely different histories.

4 changed files with 5 additions and 14 deletions

View File

@ -27,9 +27,9 @@ func RootDir() string {
return rootDir
}
func NewConfig(envFilePath string) *Config {
if envFilePath != "" {
err := godotenv.Load(envFilePath)
func NewConfig(isProd bool) *Config {
if !isProd {
err := godotenv.Load(RootDir() + "/.env")
if err != nil {
log.Fatalf("environment variable ENV is empty and an error occurred while loading the .env file\n")
}

1
go.mod
View File

@ -10,7 +10,6 @@ require (
)
require (
gitea.urkob.com/urko/go-root-dir v0.0.0-20230226084401-f50cf1a3ecf4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.0.0-20220908164124-27713097b956 // indirect

2
go.sum
View File

@ -1,5 +1,3 @@
gitea.urkob.com/urko/go-root-dir v0.0.0-20230226084401-f50cf1a3ecf4 h1:MW/orsvrClFsnh23qbDiU+D5Kg/AWcBQE3WPzrBmKl4=
gitea.urkob.com/urko/go-root-dir v0.0.0-20230226084401-f50cf1a3ecf4/go.mod h1:tEv2tp+/KhJt9OiaLpq8Ln81FtkADpeTH5nJxl8UFUA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

10
main.go
View File

@ -1,7 +1,6 @@
package main
import (
"flag"
"log"
"os"
"os/signal"
@ -18,13 +17,8 @@ var (
)
func main() {
envFilePath := ""
if os.Getenv("ENV") != "prod" {
flag.StringVar(&envFilePath, ".env path", "/", "provide .env path file as an absolute path")
flag.Parse()
}
config := cfg.NewConfig(envFilePath)
isProd := os.Getenv("ENV") == "prod"
config := cfg.NewConfig(isProd)
notifierIface = watcher.NewNotifier()
watcherIface = watcher.NewWatcher(notifierIface, pkgwatcher.Deploy)