logo-MindMajix
PostGoLangGoLang
v
veerubhotla sowmithri

Posted on 24th July 2024|74 views

0
votes

Golang Dependency Injection

What is dependency injection in Golang?

1 answers
Answers
P
kumar san

Posted on 24th July 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(),

  }

}

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos
Name
Course *
Email *
Phone Number