package
module
Version:
v1.0.0
Opens a new window with list of versions in this module.
Published: May 19, 2023
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
dotenv
A simple .env file loader for go(golang)

Install
go get github.com/radulucut/dotenv
Usage
.env
MY_VAR=some value
SECRET_KEY="s3cret"
SINGLE_QUOTE='some "value"'
main.go
package main
import (
"log"
"os"
"github.com/radulucut/dotenv"
)
func main() {
err := dotenv.Load(".env")
if err != nil {
log.Fatal("Error loading .env file")
}
myVar := os.Getenv("MY_VAR")
secretKey := os.Getenv("SECRET_KEY")
singleQuote := os.Getenv("SINGLE_QUOTE")
// ...
}
Notes:
- Overrides existing variables
- Does not trim spaces
- Does not support comments
Documentation
¶
Reads your env file and loads it into ENV for this process.
It overrides existing variables
Source Files
¶
Click to show internal directories.
Click to hide internal directories.