E0326: Two handles share a name
A page backed by a component gives its component one handle per exported field (its json name, first letter lower-cased: Q → live.q) and per callable method (Cancel → live.cancel). Two fields, or a field and a method, would have the same handle. Reported by vuka vet, the editor, and at boot, and by vukavet.
Wrong
vuka
type Orders struct {
ui.Live
Cancel bool
}
func (o *Orders) Cancel(ctx context.Context, id int64) error { … }go
// A Go type can't have a field and a method of one name; two fields can
// share a json name:
type Orders struct {
ui.Live
Q string `json:"q"`
Query string `json:"q"`
}Right
vuka
type Orders struct {
ui.Live
CanCancel bool
}
func (o *Orders) Cancel(ctx context.Context, id int64) error { … }go
type Orders struct {
ui.Live
CanCancel bool
}
func (o *Orders) Cancel(ctx context.Context, id int64) error { return nil }
func (o *Orders) Render() ui.Node { return ui.IslandPage(o) }
func NewOrders() *Orders { return &Orders{} }
func init() { web.Routes.Live("/orders", NewOrders, ui.Island()) }