This repository was archived by the owner on Jan 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,31 @@ content := getRemoteFileContent()
110
110
myEnv , err := godotenv.Unmarshal (content)
111
111
```
112
112
113
+ ### Precendence & Conventions
114
+
115
+ Existing envs take precendence of envs that are loaded later.
116
+
117
+ The [ convention] ( https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use )
118
+ for managing multiple environments (i.e. development, test, production)
119
+ is to create an env named ` {YOURAPP}_ENV ` and load envs in this order:
120
+
121
+ ``` go
122
+ env := os.Getenv (" FOO_ENV" )
123
+ if " " == env {
124
+ env = " development"
125
+ }
126
+
127
+ godotenv.Load (" .env." + env + " .local" )
128
+ if " test" != env {
129
+ godotenv.Load (" .env.local" )
130
+ }
131
+ godotenv.Load (" .env." + env)
132
+ godotenv.Load () // The Original .env
133
+ ```
134
+
135
+ If you need to, you can also use ` godotenv.Overload() ` to defy this convention
136
+ and overwrite existing envs instead of only supplanting them. Use with caution.
137
+
113
138
### Command Mode
114
139
115
140
Assuming you've installed the command as above and you've got ` $GOPATH/bin ` in your ` $PATH `
You can’t perform that action at this time.
0 commit comments