Package: env

Environment variable loader and config helper for Go applications.

dracory/env

A tiny Go package for managing environment configuration. Works standalone or as part of Dracory.

Repository: https://github.com/dracory/env

Installation

go get github.com/dracory/env

Quick Start

package main

import (
    "fmt"
    "github.com/dracory/env"
)

func main() {
    // Optionally load a .env file
    _ = env.Load(".env")

    // Read variables with defaults
    port := env.GetString("APP_PORT", "8080")
    debug := env.GetBool("APP_DEBUG", false)

    fmt.Println("Port:", port, "Debug:", debug)
}

Features

  • Load from .env files with Load() (optional)
  • Type helpers: GetString, GetInt, GetBool, GetDuration
  • Defaults when variables are missing
  • Minimal dependency footprint

Environment File Example

APP_NAME=Dracory
APP_ENV=local
APP_DEBUG=true
APP_PORT=8080

Notes

  • Follows Go best practices for env configuration
  • Safe to use in any Go project
Menu