You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
453 B
30 lines
453 B
10 months ago
|
package definition
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
func New() Definition {
|
||
|
return Definition{}
|
||
|
}
|
||
|
|
||
|
type Definition struct {
|
||
|
options Options
|
||
|
}
|
||
|
|
||
|
func (d *Definition) Add(opts ...Option) *Definition {
|
||
|
d.options = append(d.options, opts...)
|
||
|
|
||
|
return d
|
||
|
}
|
||
|
|
||
|
func (d *Definition) View(handle func(Option) error) error {
|
||
|
for idx, opt := range d.options {
|
||
|
if err := handle(opt); err != nil {
|
||
|
return fmt.Errorf("%s[%d]:%w", opt.Kind(), idx, err)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|