Skip to content
This repository has been archived by the owner on Mar 27, 2022. It is now read-only.
/ godotenv Public archive

Reading .env file and enviroment variables in golang

License

Notifications You must be signed in to change notification settings

f9n/godotenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

godotenv

Reading .env file in golang

Download

  $ go get github.com/pleycpl/godotenv    # First download repo in go directory

Usage

Example Env file (.env)
Key=Value
Mongo=20830
Token=asd123asdasd234
Usage in code
  package main
  
  import (
    "fmt"
    "github.com/pleycpl/godotenv"
  )
  
  func main() {
    env := godotenv.Godotenv(".env")        // You should write your .env file's path.
    fmt.Println(env)                        // env variable is map.
    fmt.Println(env["Key"])
    fmt.Println(env["Mongo"])
    fmt.Println(env["Token"])
  }

About

Reading .env file and enviroment variables in golang

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages