Documentation ¶
Overview ¶
Package yachg provides observable config values and tools to watch config files for changes while a program is running.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Obs ¶
type Obs[T comparable] struct { change.Obs[T] // contains filtered or unexported fields }
Example (Json) ¶
var cfg struct { Log Obs[bool] } cfg.Log.ObsRegister(0, nil, change.UpdateFunc(func(_ any, e change.Event) { ce := e.(change.Changed[bool]) fmt.Printf("%t -> %t", ce.OldValue(), ce.NewValue()) })) json.NewEncoder(os.Stdout).Encode(&cfg) json.Unmarshal([]byte(`{"Log": true}`), &cfg)
Output: {"Log":false} false -> true
func (*Obs[T]) MarshalJSON ¶
func (*Obs[T]) UnmarshalJSON ¶
type On ¶
type On[T comparable] struct { change.On[T] // contains filtered or unexported fields }
Example (Json) ¶
cfg := struct { Log On[bool] }{ Log: NewOn(false, testHook[bool](os.Stdout)), } json.NewEncoder(os.Stdout).Encode(&cfg) json.Unmarshal([]byte(`{"Log": true}`), &cfg)
Output: {"Log":false} false -> true
func (*On[T]) MarshalJSON ¶
func (*On[T]) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.