blasphem/pkg/component/reg/registry.go

25 lines
346 B
Go
Raw Normal View History

2022-12-20 11:34:25 -05:00
package reg
import (
"fmt"
"dynatron.me/x/blasphem/pkg/component"
)
2022-12-20 13:16:30 -05:00
type (
Key string
)
type Instance = component.Instance
var Registry = make(map[Key]component.Setup)
2022-12-20 11:34:25 -05:00
2022-12-20 13:16:30 -05:00
func Register(key Key, c component.Setup) {
2022-12-20 11:34:25 -05:00
_, already := Registry[key]
if already {
panic(fmt.Sprintf("component %s already exists", key))
}
Registry[key] = c
}