You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// will repeatedly attempt to pull values out of `c` until a value matching "bar" is received.
196
196
//
197
-
// Finally, if you want to have a reference to the value *sent* to the channel you can pass the `Receive` matcher a pointer to a variable of the appropriate type:
197
+
// Furthermore, if you want to have a reference to the value *sent* to the channel you can pass the `Receive` matcher a pointer to a variable of the appropriate type:
// Finally, if you want to match the received object as well as get the actual received value into a variable, so you can reason further about the value received,
205
+
// you can pass a pointer to a variable of the approriate type first, and second a matcher:
// Consume optional POINTER arg first, if it ain't no matcher ;)
47
+
resultReference=arg
48
+
args=args[1:]
49
+
}
50
+
}
51
+
iflen(args) >0 {
52
+
arg:=args[0]
53
+
subMatcher, hasSubMatcher=arg.(omegaMatcher)
35
54
if!hasSubMatcher {
36
-
argType:=reflect.TypeOf(matcher.Arg)
37
-
ifargType.Kind() !=reflect.Ptr {
38
-
returnfalse, fmt.Errorf("Cannot assign a value from the channel:\n%s\nTo:\n%s\nYou need to pass a pointer!", format.Object(actual, 1), format.Object(matcher.Arg, 1))
39
-
}
55
+
// At this point we assume the dev user wanted to assign a received
56
+
// value, so [POINTER,]MATCHER.
57
+
returnfalse, fmt.Errorf("Cannot assign a value from the channel:\n%s\nTo:\n%s\nYou need to pass a pointer!", format.Object(actual, 1), format.Object(arg, 1))
40
58
}
59
+
// Consume optional MATCHER arg.
60
+
args=args[1:]
61
+
}
62
+
iflen(args) >0 {
63
+
// If there are still args present, reject all.
64
+
returnfalse, errors.New("Receive matcher expects at most an optional pointer and/or an optional matcher")
returnfalse, fmt.Errorf("Cannot assign a value from the channel:\n%s\nType:\n%s\nTo:\n%s", format.Object(actual, 1), format.Object(value.Interface(), 1), format.Object(matcher.Arg, 1))
108
+
returnfalse, fmt.Errorf("Cannot assign a value from the channel:\n%s\nType:\n%s\nTo:\n%s", format.Object(actual, 1), format.Object(value.Interface(), 1), format.Object(resultReference, 1))
0 commit comments