uber-go / dig

A reflection based dependency injection toolkit for Go.
https://go.uber.org/dig
MIT License
3.78k stars 206 forks source link

Allow using dig.As with dig.Group #375

Closed tchung1118 closed 1 year ago

tchung1118 commented 1 year ago

This PR adds the ability to use dig.As with dig.Group. When dig.As is used with dig.Group, the value produced by the constructor will be provided to the specified group as the type specified by dig.As.

 c.Provide(newBuffer, dig.As(new(io.Reader)), dig.Group("readers"))

For example, the above code is equivalent to the following.

 c.Provide(func(...) io.Reader {
   b := newBuffer(...)
   return b
 }, dig.Group("readers"))

Fixes #341

codecov[bot] commented 1 year ago

Codecov Report

Merging #375 (24e9c43) into master (5ae7b1f) will increase coverage by 0.01%. The diff coverage is 100.00%.

:exclamation: Current head 24e9c43 differs from pull request most recent head 5596d66. Consider uploading reports for the commit 5596d66 to get more accurate results

@@            Coverage Diff             @@
##           master     #375      +/-   ##
==========================================
+ Coverage   98.33%   98.35%   +0.01%     
==========================================
  Files          21       21              
  Lines        1441     1458      +17     
==========================================
+ Hits         1417     1434      +17     
  Misses         15       15              
  Partials        9        9              
Impacted Files Coverage Δ
provide.go 100.00% <100.00%> (ø)
result.go 99.01% <100.00%> (+0.09%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

sywhang commented 1 year ago

looks like our GH account has some billing issues, OSPO is already working on fixing that.