Documentation
¶
Overview ¶
Package hotreload implements helpers around code hot reloading.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrConfigInvalid reports that the configuration is invalid. ErrConfigInvalid = errors.New("configuration is invalid") // ErrChannelClosed reports that a channel has been closed. ErrChannelClosed = errors.New("channel closed") // ErrBuildPathDoesNotExist reports that the build path does not exist. ErrBuildPathDoesNotExist = errors.New("build path does not exist") )
Functions ¶
func Start ¶
Start hot-reloads the code, logging using slog.
Example ¶
package main
import (
"log/slog"
"codeberg.org/kema/kmicro/pkg/hotreload"
)
func main() {
err := hotreload.Start(
hotreload.WithBuildPath("./cmd/hello"),
)
if err != nil {
slog.Error("hot reloading", slog.String("error.message", err.Error()))
return
}
}
Output:
Types ¶
type Option ¶
type Option func(*config)
Option configures hot reloading.
func WithBuildPath ¶
WithBuildPath sets the executable path passed to `go build`.
func WithDebounce ¶
WithDebounce sets the event coalescing delay before triggering a rebuild.
func WithExtensions ¶
WithExtensions sets the file extensions that trigger rebuilds.
func WithIgnoreDirs ¶
WithIgnoreDirs sets directory names that are skipped while watching.
func WithKillGracePeriod ¶
func WithKillGracePeriod(d