File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,13 @@ reader := getRemoteFile()
103
103
myEnv , err := godotenv.Parse (reader)
104
104
```
105
105
106
+ ... or from a ` string ` if you so desire
107
+
108
+ ``` go
109
+ content := getRemoteFileContent ()
110
+ myEnv , err := godotenv.Unmarshal (content)
111
+ ```
112
+
106
113
### Command Mode
107
114
108
115
Assuming you've installed the command as above and you've got ` $GOPATH/bin ` in your ` $PATH `
@@ -113,6 +120,22 @@ godotenv -f /some/path/to/.env some_command with some args
113
120
114
121
If you don't specify ` -f ` it will fall back on the default of loading ` .env ` in ` PWD `
115
122
123
+ ### Writing Env Files
124
+
125
+ Godotenv can also write a map representing the environment to a correctly-formatted and escaped file
126
+
127
+ ``` go
128
+ env , err := godotenv.Unmarshal (" KEY=value" )
129
+ err := godotenv.Write (env, " ./.env" )
130
+ ```
131
+
132
+ ... or to a string
133
+
134
+ ``` go
135
+ env , err := godotenv.Unmarshal (" KEY=value" )
136
+ content , err := godotenv.Marshal (env)
137
+ ```
138
+
116
139
## Contributing
117
140
118
141
Contributions are most welcome! The parser itself is pretty stupidly naive and I wouldn't be surprised if it breaks with edge cases.
You can’t perform that action at this time.
0 commit comments