Help us shape the future of Go! Take the 2026 Go Developer Survey

hook

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hook

type Hook struct {
	Name        string
	Description string
	Scripts     []*Script
}

Hook represents a hook point with attached scripts

type Registry

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

Registry manages hooks and their scripts

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new hook registry

func (*Registry) AddScript

func (r *Registry) AddScript(hookName string, script *Script) error

AddScript adds a script to a hook. Upsert semantics: a script with the same name replaces the existing one — this is what makes script hot-reload (re-register after source change) work.

func (*Registry) Clear

func (r *Registry) Clear()

Clear removes all hooks and scripts

func (*Registry) Count

func (r *Registry) Count() int

Count returns the total number of registered hooks

func (*Registry) GetAllHooks

func (r *Registry) GetAllHooks() []*Hook

GetAllHooks returns all hooks with their scripts

func (*Registry) GetHook

func (r *Registry) GetHook(name string) (*Hook, error)

GetHook returns a hook by name

func (*Registry) GetScripts

func (r *Registry) GetScripts(hookName string) []*Script

GetScripts returns all scripts for a hook

func (*Registry) ListHooks

func (r *Registry) ListHooks() []string

ListHooks returns all registered hook names

func (*Registry) RegisterHook

func (r *Registry) RegisterHook(name, description string) error

RegisterHook registers a new hook point

func (*Registry) RemoveScript

func (r *Registry) RemoveScript(hookName, scriptName string) error

RemoveScript removes a script from a hook

func (*Registry) ScriptCount

func (r *Registry) ScriptCount() int

ScriptCount returns the total number of scripts across all hooks

type Script

type Script struct {
	ID          uint32
	Name        string
	Hook        string
	Source      string
	Enabled     bool
	Priority    int
	Description string
	Version     int
	Author      string
	Critical    bool
}

Script is imported from parent package to avoid circular dependency

Jump to

Keyboard shortcuts

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