Posted on 16th September 2024|74 views
What is dependency injection in Golang?
Posted on 16th September 2024| views
Dependency Injection means the view that your components which are usual structs within go should get their dependencies while being built. That runs counter over the associated anti-pattern like components making their private dependencies through initialization. Let us see at an example.
type Server struct {
config *Config
}
func New() *Server {
return &Server{
config: buildConfigAnyhow(),
}
}