dev

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package dev provides development-only features like hot reload. These features should only be enabled in development mode.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DevReloadScript

func DevReloadScript() string

DevReloadScript returns the Datastar attribute for hot reload. Use this in templates to enable hot reload in dev mode.

func IsDev

func IsDev() bool

IsDev returns true if the application is running in development mode. Checks GO_ENV environment variable. Requires explicit "development" or "dev" value.

Types

type HotReload

type HotReload struct {
	// contains filtered or unexported fields
}

HotReload manages development hot reload functionality. It maintains SSE connections to all connected browsers and can trigger page reloads when files change.

func NewHotReload

func NewHotReload() *HotReload

NewHotReload creates a new hot reload manager.

func (*HotReload) HandleReloadSSE

func (h *HotReload) HandleReloadSSE(w http.ResponseWriter, r *http.Request)

HandleReloadSSE handles the SSE connection that triggers page reload. Browsers connect to this endpoint and wait for reload signals. On initial connection (or reconnection after server restart), it triggers an immediate reload.

func (*HotReload) HandleTriggerReload

func (h *HotReload) HandleTriggerReload(w http.ResponseWriter, r *http.Request)

HandleTriggerReload triggers a reload for all connected clients. Call this endpoint (e.g., via curl) when files change.

func (*HotReload) SetupRoutes

func (h *HotReload) SetupRoutes(mux *http.ServeMux)

SetupRoutes registers hot reload routes on the given mux. Only call this in development mode.

Jump to

Keyboard shortcuts

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