https://github.com/goapt/dotenv
golang get Env in dotfile
https://github.com/goapt/dotenv
Last synced: 10 months ago
JSON representation
golang get Env in dotfile
- Host: GitHub
- URL: https://github.com/goapt/dotenv
- Owner: goapt
- Created: 2020-03-18T02:46:01.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-18T04:03:53.000Z (almost 6 years ago)
- Last Synced: 2023-07-27T14:42:17.125Z (over 2 years ago)
- Language: Go
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Usage
Add your application configuration to your .env file in the root of your project:
```shell script
S3_BUCKET=YOURS3BUCKET
SECRET_KEY=YOURSECRETKEYGOESHERE
```
Then in your Go app you can do something like
```go
package main
import (
"log"
"os"
"github.com/goapt/dotenv"
)
func main() {
err := dotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
s3Bucket := os.Getenv("S3_BUCKET")
secretKey := os.Getenv("SECRET_KEY")
// now do something with s3 or whatever
}
```
## Thanks
https://github.com/joho/godotenv