mirror of
https://github.com/mum4k/termdash.git
synced 2025-04-25 13:48:50 +08:00
Validate the tree only once at creation.
This commit is contained in:
parent
461a242338
commit
0f0f1d4bc8
@ -84,6 +84,9 @@ func New(t terminalapi.Terminal, opts ...Option) (*Container, error) {
|
||||
if err := applyOptions(root, opts...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := validateOptions(root); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return root, nil
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,11 @@ func applyOptions(c *Container, opts ...Option) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateOptions validates options set in the container tree.
|
||||
func validateOptions(c *Container) error {
|
||||
// ensure all the container identifiers are either empty or unique.
|
||||
var errStr string
|
||||
seenID := map[string]bool{}
|
||||
|
Loading…
x
Reference in New Issue
Block a user