only check exported fields
diff --git a/params.go b/params.go
index 3341584..14b3e28 100644
--- a/params.go
+++ b/params.go
@@ -32,6 +32,11 @@
v := optsValue.Field(i)
f := optsType.Field(i)
+ if f.Name != strings.Title(f.Name) {
+ fmt.Printf("Skipping field: %s...\n", f.Name)
+ continue
+ }
+
fmt.Printf("Starting on field: %s...\n", f.Name)
zero := isZero(v)
@@ -46,7 +51,7 @@
// if the field has a required tag that's set to "true"
if requiredTag := f.Tag.Get("required"); requiredTag == "true" {
- fmt.Printf("Checking required field [%s]:\n\tv: %+v\n\tisZero:%v\n", f.Name, v.Interface(), zero)
+ //fmt.Printf("Checking required field [%s]:\n\tv: %+v\n\tisZero:%v\n", f.Name, v.Interface(), zero)
// if the field's value is zero, return a missing-argument error
if zero {
// if the field has a 'required' tag, it can't have a zero-value
@@ -57,7 +62,7 @@
}
if xorTag := f.Tag.Get("xor"); xorTag != "" {
- fmt.Printf("Checking `xor` tag for field [%s] with value %+v:\n\txorTag: %s\n", f.Name, v, xorTag)
+ //fmt.Printf("Checking `xor` tag for field [%s] with value %+v:\n\txorTag: %s\n", f.Name, v, xorTag)
xorField := optsValue.FieldByName(xorTag)
var xorFieldIsZero bool
if reflect.ValueOf(xorField.Interface()) == reflect.Zero(xorField.Type()) {
@@ -77,8 +82,8 @@
}
if orTag := f.Tag.Get("or"); orTag != "" {
- fmt.Printf("Checking `or` tag for field with:\n\tname: %+v\n\torTag:%s\n", f.Name, orTag)
- fmt.Printf("field is zero?: %v\n", zero)
+ //fmt.Printf("Checking `or` tag for field with:\n\tname: %+v\n\torTag:%s\n", f.Name, orTag)
+ //fmt.Printf("field is zero?: %v\n", zero)
if zero {
orField := optsValue.FieldByName(orTag)
var orFieldIsZero bool
@@ -101,7 +106,7 @@
if v.Kind() == reflect.Struct || (v.Kind() == reflect.Ptr && v.Elem().Kind() == reflect.Struct) {
if zero {
- fmt.Printf("value before change: %+v\n", optsValue.Field(i))
+ //fmt.Printf("value before change: %+v\n", optsValue.Field(i))
if jsonTag := f.Tag.Get("json"); jsonTag != "" {
jsonTagPieces := strings.Split(jsonTag, ",")
if len(jsonTagPieces) > 1 && jsonTagPieces[1] == "omitempty" {
@@ -111,14 +116,14 @@
v.Set(reflect.Zero(v.Type()))
}
}
- fmt.Printf("value after change: %+v\n", optsValue.Field(i))
+ //fmt.Printf("value after change: %+v\n", optsValue.Field(i))
}
}
}
continue
}
- fmt.Printf("Calling BuildRequestBody with:\n\tv: %+v\n\tf.Name:%s\n", v.Interface(), f.Name)
+ //fmt.Printf("Calling BuildRequestBody with:\n\tv: %+v\n\tf.Name:%s\n", v.Interface(), f.Name)
_, err := BuildRequestBody(v.Interface(), f.Name)
if err != nil {
return nil, err
@@ -126,14 +131,14 @@
}
}
- fmt.Printf("opts: %+v \n", opts)
+ //fmt.Printf("opts: %+v \n", opts)
b, err := json.Marshal(opts)
if err != nil {
return nil, err
}
- fmt.Printf("string(b): %s\n", string(b))
+ //fmt.Printf("string(b): %s\n", string(b))
err = json.Unmarshal(b, &optsMap)
if err != nil {
@@ -228,6 +233,7 @@
var t time.Time
func isZero(v reflect.Value) bool {
+ fmt.Printf("\n\nchecking isZero for value: %+v\n", v)
switch v.Kind() {
case reflect.Ptr:
if v.IsNil() {
@@ -257,6 +263,7 @@
}
// Compare other types directly:
z := reflect.Zero(v.Type())
+ fmt.Printf("zero type for value: %+v\n\n\n", z)
return v.Interface() == z.Interface()
}