Skip to content

Instantly share code, notes, and snippets.

@HartS

HartS/first.env Secret

Created August 15, 2017 23:58
Show Gist options
  • Save HartS/c8b5113df46f8b40e118a4799804160e to your computer and use it in GitHub Desktop.
Save HartS/c8b5113df46f8b40e118a4799804160e to your computer and use it in GitHub Desktop.
godotenv inconsistency
PRIORITY=first.env
PRIORITY=last.env
package main
import (
"fmt"
"os"
"github.com/joho/godotenv"
)
func main() {
envFiles := []string{"first.env", "last.env"}
// Read variables to environment
godotenv.Load(envFiles...)
fmt.Println(os.Getenv("PRIORITY")) // prints 'first.env', consistent with ruby dotenv
// Read variables to map
vars, _ := godotenv.Read(envFiles...)
fmt.Println(vars["PRIORITY"]) // prints 'last.env'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment