Dotenv

gogo can load environment variables from .env files. Variables are injected into task commands but don’t override existing environment variables.

Global Dotenv

The top-level dotenv field loads .env files for all tasks:

dotenv:
  - .env
  - .env.local

Per-Task Dotenv

Each task can also define its own dotenv files. These are resolved relative to the task’s working directory and are loaded in addition to global dotenv files. Per-task values override global dotenv values for that task.

dotenv:
  - .env

tasks:
  api:
    dotenv:
      - .env.api
    cmd: go run ./cmd/api

  worker:
    dir: services/worker
    dotenv:
      - .env.worker
    cmd: go run .

File Format

Standard .env format with support for comments, quoted values, and an optional export prefix:

# Database config
DB_HOST=localhost
DB_PORT=5432
DB_NAME="myapp_dev"
DB_PASSWORD='s3cret'

# An `export` prefix is allowed and ignored
export API_TOKEN=abc123

Quoting rules:

Keys must match [A-Za-z_][A-Za-z0-9_]*; invalid lines cause a parse error.

Resolution Rules

With Includes

When using includes, each included task file can define its own dotenv files. Files are deduplicated by absolute path — the same .env file is never loaded twice.