title: Golang/gin: How to Pass db to router functions
body: <p>I'm using <strong>gin framework</strong>. And I'm opening the sqlite database in the main function like this</p>
  
  <pre><code>func main() {
  ...
  db, err := sql.Open("sqlite3", "./libreread.db")
  CheckError(err)
  defer db.Close()
  ...
  }
  </code></pre>
  
  <p>And I have these router handlers in the main function.</p>
  
  <pre><code>...
  r.GET("/", GetHomePage)
  r.GET("/signin", GetSignIn)
  r.POST("/signin", PostSignIn)
  ...
  </code></pre>
  
  <p>How to pass that db value through the router handler func <code>PostSignin(c *gin.Context)</code> ?</p>
  
  <p>So that I could avoid opening and closing the database each time in the functions.</p>
  
  <p><strong>UPDATE: I'm using go-sqlite3 package.</strong></p>
  
  <p>Thanks!</p>