From db16b0807ba1eef8399810bab20eb0bdc47cb056 Mon Sep 17 00:00:00 2001 From: casjay Date: Sun, 21 Jun 2026 16:46:02 -0400 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Make=20GO=5FMODE=20canonic?= =?UTF-8?q?al;=20MODE=20becomes=20alias=20=E2=99=BB=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GO_MODE fits the GO_* naming convention. MODE is kept as a convenience alias. Resolution order: GO_MODE → MODE → GO_PROD=1 (legacy). - rootfs/usr/local/bin/go-workflow: resolve _RESOLVED_MODE from GO_MODE with MODE as fallback; warn message now references GO_MODE; logic otherwise unchanged - README.md: rename MODE row to GO_MODE (canonical); add MODE row as alias; update production mode section to use GO_MODE=prod README.md rootfs/usr/local/bin/go-workflow --- README.md | 19 ++++++++++--------- rootfs/usr/local/bin/go-workflow | 14 ++++++++------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index cbacbd0..26aff35 100644 --- a/README.md +++ b/README.md @@ -34,17 +34,17 @@ docker run --rm -v "$PWD:/app" casjaysdev/go:latest ### Production mode -Set `MODE=prod` to strip binaries for release: `-trimpath` removes all local -file system paths; `-ldflags=-s -w` strips the symbol table and DWARF debug -info. Applied to `go build` only — `go test` is unaffected so stack traces -stay readable. +Set `GO_MODE=prod` to strip binaries for release: `-trimpath` removes all +local file system paths; `-ldflags=-s -w` strips the symbol table and DWARF +debug info. Applied to `go build` only — `go test` is unaffected so stack +traces stay readable. ```shell -docker run --rm -v "$PWD:/app" -e MODE=prod casjaysdev/go:latest +docker run --rm -v "$PWD:/app" -e GO_MODE=prod casjaysdev/go:latest ``` -`MODE=production` is also accepted. `GO_PROD=1` is a legacy alias that still -works when `MODE` is not set. +`GO_MODE=production` is also accepted. `MODE` is an alias for `GO_MODE`. +`GO_PROD=1` is a legacy alias that still works when `GO_MODE` is not set. ### One-shot commands @@ -203,8 +203,9 @@ volumes: | `GOFLAGS` | `-buildvcs=false` | Suppress VCS stamp errors on mounted projects | | `GOPROXY` | `https://proxy.golang.org,direct` | Module proxy — override for private registries | | `GOTELEMETRY` | `off` | Disable Go 1.23+ telemetry | -| `MODE` | `development` | Build mode: `prod`/`production` or `dev`/`devel`/`development` | -| `GO_PROD` | *(unset)* | Legacy alias for `MODE=prod` — set to `1`; superseded by `MODE` | +| `GO_MODE` | `development` | Build mode: `prod`/`production` or `dev`/`devel`/`development` | +| `MODE` | *(unset)* | Alias for `GO_MODE` — `GO_MODE` takes precedence when both are set | +| `GO_PROD` | *(unset)* | Legacy alias — `GO_PROD=1` equals `GO_MODE=prod`; superseded by `GO_MODE` | | `TZ` | `America/New_York` | Override at run time with `-e TZ=...` | Opt into CGO per build without changing the image: diff --git a/rootfs/usr/local/bin/go-workflow b/rootfs/usr/local/bin/go-workflow index 5d547a5..21c1cd4 100755 --- a/rootfs/usr/local/bin/go-workflow +++ b/rootfs/usr/local/bin/go-workflow @@ -29,19 +29,21 @@ run_step() { echo "" } -# Resolve build mode from MODE or the legacy GO_PROD=1 flag. -# MODE=prod|production → strip binary (-trimpath -ldflags=-s -w); applied to go build only -# MODE=dev|devel|development → default; full debug info, readable stack traces -# GO_PROD=1 is kept for backwards compatibility and takes effect when MODE is unset. +# Resolve build mode. Resolution order (first non-empty value wins): +# GO_MODE — canonical name; prod|production or dev|devel|development +# MODE — alias for GO_MODE (accepted for convenience) +# GO_PROD — legacy flag; GO_PROD=1 maps to production mode +# -trimpath -ldflags=-s -w applied to go build only; go test is unaffected. +_RESOLVED_MODE="${GO_MODE:-${MODE:-}}" _IS_PROD=0 -case "${MODE:-}" in +case "${_RESOLVED_MODE}" in prod | production) _IS_PROD=1 ;; dev | devel | development) _IS_PROD=0 ;; "") [ "${GO_PROD:-0}" = "1" ] && _IS_PROD=1 ;; *) - echo "Warning: unknown MODE '${MODE}' — expected prod|production|dev|devel|development; defaulting to development" >&2 + echo "Warning: unknown GO_MODE '${_RESOLVED_MODE}' — expected prod|production|dev|devel|development; defaulting to development" >&2 ;; esac