Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
  • Loading branch information
suqin-haha authored and muir committed Aug 23, 2024
1 parent 58aedaa commit 729c98a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func makeIntDoublerWithError(t reflect.Type) (func(v reflect.Value), error) {
if f.Type.Kind() == reflect.String {
return errors.Errorf("error on string, and stop walk")
}
return nil // default nil recursive down
return nil // return nil will recurse on a field that is struct
})
return func(v reflect.Value) {
v = v.Elem()
Expand Down Expand Up @@ -109,7 +109,8 @@ func Example() {
fmt.Printf("%v\n", v.Interface())
fmt.Printf("%v", err)

// Output: &{6 {4 12} string {10}}
// Output:
// &{6 {4 12} string {10}}
// &{12 {4 12} string {10}}
// <nil>
}
Expand All @@ -132,6 +133,7 @@ func ExampleError() {
fmt.Printf("%v\n", v.Interface())
fmt.Printf("%v", err)

// Output: &{6 {4 12} string {5}}
// Output:
// &{6 {4 12} string {5}}
// error on string, and stop walk
}

0 comments on commit 729c98a

Please sign in to comment.