dev

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package dev provides dev-mode-only helpers (livereload, debug surfaces). Everything in this package no-ops in production by design.

Index

Constants

View Source
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

func MaybeRegisterLiveReload(r *router.Router)

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

func RegisterLiveReload(r *router.Router)

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

func SetHeartbeatIntervalForTest(_ interface{ Helper() }, d time.Duration) func()

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.

Jump to

Keyboard shortcuts

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