Skip to content

eddogola/readenv

Repository files navigation

readenv

codecov Go Reference Build Status Go Report Card

A simple Go library to read environment variables files(.env files).

Installing

go get -u github.com/eddogola/readenv

Usage

The library basically parses the (file) byte data into a map, from which users can Get environment variables.

import (
    "os"

    "github.com/eddogola/readenv"
)

func main() {
    file, err := os.OpenFile(".env", os.O_RDONLY, 0444) // open .env file
    if err != nil {
        // handle error
    }
    defer file.Close()
    
    envData, err := readenv.ReadEnv(file)
    if err != nil {
        // handle error
    }

    val, err := envData.Get("<YOUR_.ENV_VAR>")) // access specific variables using their keys
    if err != nil {
        // handle error
    }
    fmt.Println(val)
}

Contribution

Feel free to

  • Start issues.
  • Make pull requests.
  • Make suggestions on improvement, e.g. features

About

Reads environment variables from .env files.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages