env

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 2 Imported by: 0

README

env

Read config from the process environment, falling back to a .env file — one call works in dev and prod alike

Documentation

Overview

Package env reads configuration from the process environment, falling back to a .env file when the variable isn't set. This makes one call work both in production (real env vars) and local dev under tools like the tinywasm daemon, which runs the app binary as a child process without exporting .env into its environment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Arg added in v0.0.2

func Arg(key string) string

Arg returns the value for -key=value or -key value in os.Args (skipping argv[0]). Unset flags return "" — callers apply their own default, same as Get. Common pattern: tools like the tinywasm dev daemon pass runtime config as CLI flags to the child process instead of env vars.

func Get added in v0.0.2

func Get(key string) string

Get returns the value of key from the process environment, or — if unset — the value of key=... in path (typically ".env" in the working directory). Values wrapped in double quotes have them stripped. Returns "" if the key is set nowhere.

func GetFrom added in v0.0.2

func GetFrom(key, path string) string

GetFrom is Get with an explicit .env path, for callers not running from the project root.

func GetRequired added in v0.0.2

func GetRequired(key string, fallbackPaths ...string) (string, error)

GetRequired returns key from env, .env, or fallback paths in order. Returns an error if key is not found anywhere.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL