Skip to content

Commit

Permalink
Merge pull request #41 from alexquick/document-write-dotenv
Browse files Browse the repository at this point in the history
Document Marshal, Unmarshal, and Write
  • Loading branch information
joho authored Sep 18, 2017
2 parents 144189c + e6264cf commit a79fa1e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ reader := getRemoteFile()
myEnv, err := godotenv.Parse(reader)
```

... or from a `string` if you so desire

```go
content := getRemoteFileContent()
myEnv, err := godotenv.Unmarshal(content)
```

### Command Mode

Assuming you've installed the command as above and you've got `$GOPATH/bin` in your `$PATH`
Expand All @@ -113,6 +120,22 @@ godotenv -f /some/path/to/.env some_command with some args

If you don't specify `-f` it will fall back on the default of loading `.env` in `PWD`

### Writing Env Files

Godotenv can also write a map representing the environment to a correctly-formatted and escaped file

```go
env, err := godotenv.Unmarshal("KEY=value")
err := godotenv.Write(env, "./.env")
```

... or to a string

```go
env, err := godotenv.Unmarshal("KEY=value")
content, err := godotenv.Marshal(env)
```

## Contributing

Contributions are most welcome! The parser itself is pretty stupidly naive and I wouldn't be surprised if it breaks with edge cases.
Expand Down

0 comments on commit a79fa1e

Please sign in to comment.