Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Clarify Supply/Replace behavior with interface values #857

Merged
merged 1 commit into from Mar 9, 2022

Conversation

abhinav
Copy link
Collaborator

@abhinav abhinav commented Mar 9, 2022

Use of fx.Replace or fx.Supply with interface values can lead to
unexpected behavior. fx.Supply((io.Reader)(r)) will use the type of
the implementation r, not io.Reader.

This clarifies the documentation for both APIs to make this explicit.

Refs GO-1253, GO-1254


Previews

fx.Replace:
image

fx.Supply:
image

Use of `fx.Replace` or `fx.Supply` with interface values can lead to
unexpected behavior. `fx.Supply((io.Reader)(r))` will use the type of
the implementation `r`, not `io.Reader`.

This clarifies the documentation for both APIs to make this explicit.

Refs GO-1253
@abhinav abhinav requested a review from sywhang March 9, 2022 22:44
@codecov
Copy link

codecov bot commented Mar 9, 2022

Codecov Report

Merging #857 (ad74d0e) into master (5ebb242) will increase coverage by 0.18%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #857      +/-   ##
==========================================
+ Coverage   98.45%   98.63%   +0.18%     
==========================================
  Files          30       30              
  Lines        1100     1100              
==========================================
+ Hits         1083     1085       +2     
+ Misses         11       10       -1     
+ Partials        6        5       -1     
Impacted Files Coverage Δ
replace.go 100.00% <ø> (ø)
supply.go 100.00% <ø> (ø)
app.go 95.87% <0.00%> (+0.91%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ebb242...ad74d0e. Read the comment docs.

Copy link
Contributor

@sywhang sywhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@abhinav abhinav merged commit 6bc0d21 into master Mar 9, 2022
@abhinav abhinav deleted the abg/supply-replace-doc branch March 9, 2022 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants