Compare commits
2 Commits
4877f72f04
...
1b83793f38
Author | SHA1 | Date |
---|---|---|
Urko | 1b83793f38 | |
Urko | f56e85cc64 |
|
@ -27,9 +27,9 @@ func RootDir() string {
|
||||||
return rootDir
|
return rootDir
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig(isProd bool) *Config {
|
func NewConfig(envFilePath string) *Config {
|
||||||
if !isProd {
|
if envFilePath != "" {
|
||||||
err := godotenv.Load(RootDir() + "/.env")
|
err := godotenv.Load(envFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("environment variable ENV is empty and an error occurred while loading the .env file\n")
|
log.Fatalf("environment variable ENV is empty and an error occurred while loading the .env file\n")
|
||||||
}
|
}
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -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
2
go.sum
|
@ -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
10
main.go
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue