title: What is the best way to have dependency injection in Golang
body: <p>I'm a beginner in Golang and I'm working on a small library which need to get a DB connection at some point in the code for différent sub package / method call. I'm just wondering how I can manage this ? </p>
  
  <p>Example, If I manage to have a webserver, it works with handler, so how can I get this connection inside this function ?
  It could be used with another process, simple method call or MVC model ?</p>
  
  <p>I don't want to use global because for me it's a bad practice except if it's very exceptional way (or tricky somehow).</p>
  
  <p>I read a lot of write in different website, but still, I'm asking and learning from different opinion and experiences.</p>
  
  <p>Thanks for your time !</p>