I'd like to use facebookgo/inject, but I have a problem. I wrote this code:
package main
import (
"github.com/facebookgo/inject"
)
type BookService struct {
Database Database `inject:""`
}
type Database struct {
ConnectionString string `inject:""`
}
func main() {
var graph inject.Graph
var service BookService
_ = graph.Provide(&inject.Object{Value: &service}, &inject.Object{Value: Database{ConnectionString: "uri"}})
_ = graph.Populate()
println(service.Database.ConnectionString)
}
So, I expect that after injection the value of the field ConnectionString will be uri, but I get an empty string. What am I doing wrong?