Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Created June 12, 2019 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miguelmota/2275e6d7a35a226c4df64fd6fea7ad29 to your computer and use it in GitHub Desktop.
Save miguelmota/2275e6d7a35a226c4df64fd6fea7ad29 to your computer and use it in GitHub Desktop.
Golang dotenv (.env) example
HOST=127.0.0.1
package main
import (
"fmt"
"log"
"os"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
fmt.Println(os.Getenv("HOST")) // 127.0.0.1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment