Documentation
¶
Overview ¶
Package dev provides dev-mode-only helpers (livereload, debug surfaces). Everything in this package no-ops in production by design.
Index ¶
Constants ¶
const ( LiveReloadStreamURL = "/__livereload" LiveReloadScriptURL = "/__livereload.js" )
LiveReloadStreamURL is the SSE endpoint the dev client connects to. LiveReloadScriptURL is the tiny EventSource client script.
Variables ¶
This section is empty.
Functions ¶
func LiveReloadEnabled ¶
func LiveReloadEnabled() bool
LiveReloadEnabled reports whether dev-mode livereload should auto-wire.
Rules:
- GOFASTR_ENV looking like a non-dev environment → always off (case-insensitive: production, prod, live, staging).
- GOFASTR_DEV must be set to a strconv.ParseBool truthy value (1, t, T, TRUE, true, True) — typically by `gofastr dev`. Unparseable / falsy values keep livereload off so a stray GOFASTR_DEV="false" or ="no" never trips it on.
- GOFASTR_DEV_LIVERELOAD set to a falsy ParseBool value → opt-out even when GOFASTR_DEV is set.
- Otherwise on.
func MaybeRegisterLiveReload ¶
MaybeRegisterLiveReload calls RegisterLiveReload only if LiveReloadEnabled() returns true. Used by framework.NewApp to auto-wire without forcing the route on every test that constructs a router.
func RegisterLiveReload ¶
RegisterLiveReload installs the SSE endpoint and client script on r. Idempotent — safe to call multiple times on the same router. If the router already has either pattern registered (e.g. the host wired a hand-rolled livereload before upgrading), the call is a no-op so the upgrade path doesn't panic on http.ServeMux duplicate-pattern.
func SetHeartbeatIntervalForTest ¶
SetHeartbeatIntervalForTest swaps the SSE heartbeat interval and returns a restore function. For tests only — production callers must use the default. Pass *testing.T to make the intent unambiguous.
Types ¶
This section is empty.