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
Describe the bug
When using an annotated return type of the function along with optional tag, the tagged parameter is not nil in a if b.Client == nil comparison
It's a common gotcha, but it's completely valid to have a nil implementation in a non-nil interface.
typemyClientstruct{}
func (c*myClient) Do(req*http.Request) (*http.Response, error) {
ifc==nil {
returnhttp.DefaultClient.Do(req)
}
panic("TODO: custom logic here")
}
// Same as before:varc*myClient=nilvariHTTPClient=cfmt.Println(i==nil) // false// Can still send requests:res, err:=i.Do(req)
// ...
By providing a function that returns a nil *http.Client, and casting it to an HTTPClient, we're asking for a non-nil HTTPClient with a nil *http.Client inside it.
From Fx's point of view, this is behaving as expected.
Fx should not be trying to glean the meaning of a typed nil.
It should not discard my nil-safe implementation of an interface.
Describe the bug
When using an annotated return type of the function along with optional tag, the tagged parameter is not nil in a
if b.Client == nil
comparisonTo Reproduce
An example program:
Expected behavior
I'd expect to see a message similar to:
instead of
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: