Skip to content
psyb0tPublic

About

The most over-engineered environment variable reader in the history of Go programming. A full-blown, battle-tested, enterprise-grade package that reads ONE environment variable and tells you if you're in prod or dev.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

goenv

Go Reference CI coverage version license imported by

The most over-engineered environment variable reader in the history of Go programming. A full-blown, battle-tested, enterprise-grade package that reads ONE environment variable and tells you if you're in prod or dev.

Why does this exist?

Because os.Getenv("ENV") is 16 characters and sometimes you just need a whole fucking package to do the same thing but with ✨style✨.

Features

  • Reads the ENV environment variable. That's it. That's the feature.
  • Defaults to prod because production is where dreams go to die and that's where you probably are.
  • Can tell you if you're in dev. Revolutionary.
  • Zero dependencies. Not even fmt. I don't need that shit.
  • 100% test coverage because I'm a professional.

Install

go get github.com/psyb0t/goenv

Needs Go 1.26 or newer.

Usage

package main

import (
    "fmt"

    "github.com/psyb0t/goenv"
)

func main() {
    // Get the current environment
    env := goenv.Get() // "prod" or "dev"
    fmt.Println("running in", env)

    // Check if prod
    if goenv.IsProd() {
        fmt.Println("don't fuck this up")
    }

    // Check if dev
    if goenv.IsDev() {
        fmt.Println("break whatever you want")
    }
}

Environment variable

export ENV=dev   # you're developing
export ENV=prod  # you're in production
export ENV=      # also production, because paranoia is a feature

Only the exact, lowercase dev counts as dev. DEV, development, staging, a typo: all prod. The full table of values, every function and constant, and the Type alias are in the API reference.

Agent integrations

The skill works in any agent that reads .agents/skills/ (such as peen), installs in Claude Code and Codex from the psyb0t/agents marketplace, and lands on ClawHub for OpenClaw on every release. The install commands are on Agent integrations.

Documentation

The full docs live at psyb0t.github.io/goenv.

Page What's in it
API reference Get, IsProd, IsDev, the constants, the Type alias and which ENV values mean dev
Agent integrations Installing the skill in Claude Code, Codex and OpenClaw
Development Make targets, the coverage gate, CI and releases

FAQ

Q: Do I really need a package for this? A: No. But here we are.

Q: What if I set ENV to "staging"? A: You get prod. Because if it's not explicitly dev, it's prod. I don't trust you.

Q: What about ENV=test? A: Also prod. See above.

Q: Is this thread-safe? A: It calls os.Getenv(). Take that however you want.

Q: Why not just use os.Getenv directly? A: Because then you'd have to remember the variable name, write a switch statement, handle the default case, and before you know it you've written this package anyway.

Sponsor

Buy Me a Coffee

License

MIT. Free as in "do whatever the hell you want with it". Which, given what this package does, isn't saying much.

About

The most over-engineered environment variable reader in the history of Go programming. A full-blown, battle-tested, enterprise-grade package that reads ONE environment variable and tells you if you're in prod or dev.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages