27 lines
328 B
Go
27 lines
328 B
Go
|
package blas
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
type (
|
||
|
Setup func(Core) (Component, error)
|
||
|
Key string
|
||
|
|
||
|
Component interface {
|
||
|
Shutdown()
|
||
|
}
|
||
|
|
||
|
)
|
||
|
|
||
|
var Registry = make(map[Key]Setup)
|
||
|
|
||
|
func Register(key Key, c Setup) {
|
||
|
_, already := Registry[key]
|
||
|
if already {
|
||
|
panic(fmt.Sprintf("component %s already exists", key))
|
||
|
}
|
||
|
|
||
|
Registry[key] = c
|
||
|
}
|