File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,6 +103,13 @@ reader := getRemoteFile()
103103myEnv , err := godotenv.Parse (reader)
104104```
105105
106+ ... or from a ` string ` if you so desire
107+
108+ ``` go
109+ content := getRemoteFileContent ()
110+ myEnv , err := godotenv.Unmarshal (content)
111+ ```
112+
106113### Command Mode
107114
108115Assuming 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
113120
114121If you don't specify ` -f ` it will fall back on the default of loading ` .env ` in ` PWD `
115122
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+
116139## Contributing
117140
118141Contributions 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