编程

Goenv

试用

Go library that reads the ENV variable and returns "dev" only if exactly "dev", otherwise "prod" with boolean helpers and fail-safe defaults.

它能做什么

A Go library that reads a single environment variable — — and answers one question: are you in or ? That's the whole package. with a fail-safe default and three named helpers, zero dependencies. Import it and call .

技能文档

goenv

A Go library that reads a single environment variable — ENV — and answers one question: are you in prod or dev? That's the whole package. os.Getenv("ENV") with a fail-safe default and three named helpers, zero dependencies. Import it and call goenv.Get().

For install, the exact match/default behavior, and a worked example, see references/setup.md.

Security & safety

  • It reads exactly one environment variable — ENV — and nothing else. No other env vars are read, nothing is written to disk, no network calls are made at runtime, and no data leaves your process. Its only import is the stdlib os.
  • It's a library you compile into your own binary — it has no runtime surface of its own. Whatever your program does with the prod/dev answer is on you, same as any code you'd write by hand.
  • Fail-safe by design: an unrecognized or unset ENV resolves to prod, so a misconfigured environment errs toward production-grade behavior rather than accidentally enabling dev-only shortcuts.

When to use

  • A Go program needs a small, dependency-free way to branch behavior between two environments (prod vs dev) — e.g. verbose logging in dev, stricter defaults in prod.
  • The project already imports github.com/psyb0t/goenv and you want to add or read a prod/dev check consistently (goenv.IsProd() / goenv.IsDev() instead of hand-rolled os.Getenv comparisons).
  • You want the fail-safe "default to prod" semantics without writing the switch yourself.

When NOT to use

  • You need more than two environments (staging, test, ci, local, …) — goenv only knows dev and prod; everything that isn't exactly "dev" collapses to prod.
  • You need to read env vars other than ENV, or a configurable variable name — goenv reads the hardcoded ENV and nothing else. Reach for a real config library (e.g. gonfiguration) for anything richer.
  • You expect compile-time type safety from the Type type — it's a string alias, so goenv.Type is string; the constants are conveniences, not an enum, and any string is assignable. If you need a distinct nominal type, this isn't it.

Usage

import "github.com/psyb0t/goenv"

// The current environment as a string ("prod" or "dev"):
switch goenv.Get() {
case goenv.Dev:
    // dev-only behavior
default: // goenv.Prod
    // prod behavior
}

// Or the boolean shortcuts:
if goenv.IsDev() {
    logger.SetLevel("debug")
}
if goenv.IsProd() {
    enableStrictMode()
}

// The recognized values and the variable name are exported constants:
_ = goenv.Prod         // "prod"
_ = goenv.Dev          // "dev"
_ = goenv.EnvVarName   // "ENV"

The mapping is exact: Get() returns Dev only when ENV is precisely "dev"; every other value — unset, empty, "DEV", "development", "prod", or anything else — returns Prod. Set it before your process starts:

ENV=dev  ./yourapp     # dev
ENV=prod ./yourapp     # prod
./yourapp              # ENV unset → prod (the default)

For the module path, supported Go version, and the full behavior table, see references/setup.md.

相关技能

诊断生产力系统反复失效的根因,给出最小干预——容量测算、瓶颈定位、可靠的本地记录。

作者 Iván854 次安装69 星标

以 AI 机器人身份加入视频会议,提供语音、虚拟形象与屏幕共享四种模式。

作者 johnpatternai21 次安装8 星标

通过一次 REST API 调用,向 10 个社交平台发布视频、图片、文字与文档。

作者 victorcavero14375 次安装50 星标

通过 6551 REST API 查询 Twitter/X 用户资料、推文、粉丝事件与 KOL 数据。

作者 infra403840 次安装27 星标

在本地磁盘以分类纯 Markdown 文件保存需要长期留存的事实,与智能体内置记忆并存。

作者 Iván555 次安装18 星标

psyb0t 的更多技能

浏览全部技能

对接用户自部署的 mt5-httpapi MetaTrader 5 网关,每次涉及真实资金的写操作都必须逐笔确认后再执行。

作者 psyb0t107 次安装4 星标

面向反爬检测栈 QA 与授权测试场景的 Docker 浏览器自动化工具。

作者 psyb0t137 次安装2 星标

自托管、OpenAI 兼容的语音服务,一个容器搞定转写、翻译与合成。

作者 psyb0t13 次安装

在固定白名单的 SSH 沙箱里跑 ffmpeg、sox、ImageMagick 处理音视频和图片。

作者 psyb0t71 次安装

通过 SSH 调用 Qwen3-TTS 生成语音,支持预设音色、声音克隆与声音设计。

作者 psyb0t55 次安装

一个端点统一管控多个 IMAP/SMTP 邮箱,跨账号并行完成读取、检索、发送、标记与删除。

作者 psyb0t15 次安装