♻️ Make GO_MODE canonical; MODE becomes alias ♻️

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
This commit is contained in:
2026-06-21 16:46:02 -04:00
parent f910225d3b
commit db16b0807b
2 changed files with 18 additions and 15 deletions
+10 -9
View File
@@ -34,17 +34,17 @@ docker run --rm -v "$PWD:/app" casjaysdev/go:latest
### Production mode ### Production mode
Set `MODE=prod` to strip binaries for release: `-trimpath` removes all local Set `GO_MODE=prod` to strip binaries for release: `-trimpath` removes all
file system paths; `-ldflags=-s -w` strips the symbol table and DWARF debug local file system paths; `-ldflags=-s -w` strips the symbol table and DWARF
info. Applied to `go build` only — `go test` is unaffected so stack traces debug info. Applied to `go build` only — `go test` is unaffected so stack
stay readable. traces stay readable.
```shell ```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 `GO_MODE=production` is also accepted. `MODE` is an alias for `GO_MODE`.
works when `MODE` is not set. `GO_PROD=1` is a legacy alias that still works when `GO_MODE` is not set.
### One-shot commands ### One-shot commands
@@ -203,8 +203,9 @@ volumes:
| `GOFLAGS` | `-buildvcs=false` | Suppress VCS stamp errors on mounted projects | | `GOFLAGS` | `-buildvcs=false` | Suppress VCS stamp errors on mounted projects |
| `GOPROXY` | `https://proxy.golang.org,direct` | Module proxy — override for private registries | | `GOPROXY` | `https://proxy.golang.org,direct` | Module proxy — override for private registries |
| `GOTELEMETRY` | `off` | Disable Go 1.23+ telemetry | | `GOTELEMETRY` | `off` | Disable Go 1.23+ telemetry |
| `MODE` | `development` | Build mode: `prod`/`production` or `dev`/`devel`/`development` | | `GO_MODE` | `development` | Build mode: `prod`/`production` or `dev`/`devel`/`development` |
| `GO_PROD` | *(unset)* | Legacy alias for `MODE=prod` — set to `1`; superseded by `MODE` | | `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=...` | | `TZ` | `America/New_York` | Override at run time with `-e TZ=...` |
Opt into CGO per build without changing the image: Opt into CGO per build without changing the image:
+8 -6
View File
@@ -29,19 +29,21 @@ run_step() {
echo "" echo ""
} }
# Resolve build mode from MODE or the legacy GO_PROD=1 flag. # Resolve build mode. Resolution order (first non-empty value wins):
# MODE=prod|production → strip binary (-trimpath -ldflags=-s -w); applied to go build only # GO_MODE — canonical name; prod|production or dev|devel|development
# MODE=dev|devel|development → default; full debug info, readable stack traces # MODE — alias for GO_MODE (accepted for convenience)
# GO_PROD=1 is kept for backwards compatibility and takes effect when MODE is unset. # 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 _IS_PROD=0
case "${MODE:-}" in case "${_RESOLVED_MODE}" in
prod | production) _IS_PROD=1 ;; prod | production) _IS_PROD=1 ;;
dev | devel | development) _IS_PROD=0 ;; dev | devel | development) _IS_PROD=0 ;;
"") "")
[ "${GO_PROD:-0}" = "1" ] && _IS_PROD=1 [ "${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 esac