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

Latest commit

 

History

History
37 lines (28 loc) · 619 Bytes

README.md

File metadata and controls

37 lines (28 loc) · 619 Bytes

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"])
  }