- added Option.Field() method to recover the struct field associated with the option
- added Option.IsSetDefault() to help distinguish cases where the option was really set or set with default values
diff --git a/option.go b/option.go
index a7f4f9a..95eaedc 100644
--- a/option.go
+++ b/option.go
@@ -79,13 +79,17 @@
// Determines if the option will be always quoted in the INI output
iniQuote bool
- tag multiTag
- isSet bool
- preventDefault bool
+ tag multiTag
+ isSet, isSetDefault bool
+ preventDefault bool
defaultLiteral string
}
+func (option *Option) Field() reflect.Value {
+ return option.value
+}
+
// LongNameWithNamespace returns the option's long name with the group namespaces
// prepended by walking up the option's group tree. Namespaces and the long name
// itself are separated by the parser's namespace delimiter. If the long name is
@@ -172,6 +176,11 @@
return option.isSet
}
+// IsSetDefault returns true if option has been set with its default value.
+func (option *Option) IsSetDefault() bool {
+ return option.isSetDefault
+}
+
// Set the value of an option to the specified value. An error will be returned
// if the specified value could not be converted to the corresponding option
// value type.
@@ -266,6 +275,7 @@
for _, d := range usedDefault {
option.set(&d)
+ option.isSetDefault = true
}
} else {
tp := option.value.Type()