Skip to content

Commit

Permalink
update: simplify the loop with val.Recv() (#737)
Browse files Browse the repository at this point in the history
* update: simplify the loop with val.Recv()

* fix: walk -> walkValue for consistency of the material
  • Loading branch information
UponTheSky authored Mar 3, 2024
1 parent 25f3ab1 commit 002c2b0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions reflection.md
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,12 @@ func walk(x interface{}, fn func(input string)) {
walkValue(val.MapIndex(key))
}
case reflect.Chan:
for v, ok := val.Recv(); ok; v, ok = val.Recv() {
walkValue(v)
for {
if v, ok := val.Recv(); ok {
walkValue(v)
} else {
break
}
}
}
}
Expand Down

0 comments on commit 002c2b0

Please sign in to comment.