feat: get envfile from path when is not prod

This commit is contained in:
Urko 2023-03-03 22:47:44 +01:00
parent f56e85cc64
commit 1b83793f38
3 changed files with 11 additions and 2 deletions

1
go.mod
View File

@ -10,6 +10,7 @@ require (
) )
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/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.0.0-20220908164124-27713097b956 // indirect golang.org/x/sys v0.0.0-20220908164124-27713097b956 // indirect

2
go.sum
View File

@ -1,3 +1,5 @@
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.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 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

10
main.go
View File

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