File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ type Dotenv struct {
2828 //
2929 // - default: false - will return error if not exists
3030 IgnoreNotExist bool
31+ // LoadFirstExist only load first exists env file on Files
32+ LoadFirstExist bool
3133
3234 loadFiles []string
3335 loadData map [string ]string
@@ -72,6 +74,9 @@ func (c *Dotenv) doLoadFiles(files []string) error {
7274 if err := c .loadFile (filePath ); err != nil {
7375 return err
7476 }
77+ if c .LoadFirstExist && len (c .loadFiles ) > 0 {
78+ break
79+ }
7580 }
7681
7782 return nil
@@ -186,3 +191,8 @@ func LoadEnvFiles(baseDir string, files ...string) error {
186191 })
187192}
188193
194+ // LoadedEnvFiles get loaded dotenv files
195+ func LoadedEnvFiles () []string {
196+ return stdEnv .LoadedFiles ()
197+ }
198+
You can’t perform that action at this time.
0 commit comments