-
-
Save HartS/c8b5113df46f8b40e118a4799804160e to your computer and use it in GitHub Desktop.
godotenv inconsistency
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PRIORITY=first.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PRIORITY=last.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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