uber-go / fx

A dependency injection based application framework for Go.
https://uber-go.github.io/fx/
MIT License
5.48k stars 283 forks source link

Private supplies #1206

Closed saturn4er closed 1 month ago

saturn4er commented 1 month ago

Is your feature request related to a problem? Please describe. fx.Private doesn't work with fx.Supply. It just supplies value of option to DI container. It would be nice to be able to use fx.Private in fx.Supply function as it now works with fx.Provide function

Is this a breaking change? No, it's not

Simple code to check that fx.Supply doesn't work with fx.Private Used fx version: v1.21.1

package main

import (
    "go.uber.org/fx"
)

func main() {
    fx.New(
        fx.Module(
            "tst",
            fx.Supply(1, fx.Private),
            fx.Supply("1", fx.Private),
        ),
    )
}

output cannot provide fx.privateOption from [0]: already provided by "reflect".makeFuncStub

JacobOaks commented 1 month ago

Hey @saturn4er! This should be supported now with #1207 being merged. Will try to do a release today.