-
-
Save miguelmota/2275e6d7a35a226c4df64fd6fea7ad29 to your computer and use it in GitHub Desktop.
Golang dotenv (.env) example
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
HOST=127.0.0.1 |
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" | |
"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