|
@@ -2,6 +2,7 @@ package env
|
|
|
|
|
|
import (
|
|
import (
|
|
"bufio"
|
|
"bufio"
|
|
|
|
+ "flag"
|
|
"os"
|
|
"os"
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
@@ -10,8 +11,7 @@ import (
|
|
|
|
|
|
// nolint:gosec
|
|
// nolint:gosec
|
|
const (
|
|
const (
|
|
- envPathVar = "ENV_PATH"
|
|
|
|
- envPath = "../../config/.env"
|
|
|
|
|
|
+ envPath = "../../config/.env"
|
|
|
|
|
|
appPortEnv = "APP_PORT"
|
|
appPortEnv = "APP_PORT"
|
|
|
|
|
|
@@ -59,12 +59,10 @@ type env struct {
|
|
func Init() (interfaces.IEnv, error) {
|
|
func Init() (interfaces.IEnv, error) {
|
|
res := &env{}
|
|
res := &env{}
|
|
|
|
|
|
- path := os.Getenv(envPathVar)
|
|
|
|
- if path == "" {
|
|
|
|
- path = envPath
|
|
|
|
- }
|
|
|
|
|
|
+ path := flag.String("config", envPath, "path to .env config")
|
|
|
|
+ flag.Parse()
|
|
|
|
|
|
- file, err := os.Open(path)
|
|
|
|
|
|
+ file, err := os.Open(*path)
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|