zfs.NilBool: document its purpose and move it to its own package 'nodefault'

This commit is contained in:
Christian Schwarz
2020-09-02 22:38:26 +02:00
parent 70bbdfe760
commit 1c937e58f7
13 changed files with 104 additions and 59 deletions
+19
View File
@@ -0,0 +1,19 @@
package nodefault
import "fmt"
type Bool struct{ B bool }
func (n *Bool) ValidateNoDefault() error {
if n == nil {
return fmt.Errorf("must explicitly set `true` or `false`")
}
return nil
}
func (n *Bool) String() string {
if n == nil {
return "unset"
}
return fmt.Sprintf("%v", n.B)
}