Factor out duplicate value reset code.

This commit is contained in:
Alec Thomas
2018-05-19 22:15:14 +10:00
parent d1acfab2e6
commit d7bb20f297
2 changed files with 11 additions and 12 deletions
+8
View File
@@ -42,6 +42,14 @@ func (v *Value) Decode(scan *Scanner) error {
return err
}
func (v *Value) Reset() {
v.Value.Set(reflect.Zero(v.Value.Type()))
if v.Default != "" {
v.Decode(Scan(v.Default))
v.Set = false
}
}
type Positional = Value
type Argument struct {