1
0
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:
Jakub Sobon 2019-03-28 22:50:29 -04:00
parent 461a242338
commit 0f0f1d4bc8
No known key found for this signature in database
GPG Key ID: F2451A77FB05D3B7
2 changed files with 7 additions and 0 deletions

View File

@ -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
}

View File

@ -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{}