title: How to get values from a variable of type *sql.Rows in the view?
body: <p>In <code>posts</code> table, there are attributes like <code>title</code>, <code>content</code>.
  I can get data of type <code>*sql.Rows</code> and pass them to the view by</p>
  
  <pre><code> posts, err := db.Query("SELECT id, title FROM posts WHERE id = 1")
  </code></pre>
  
  <p>and </p>
  
  <pre><code>  err = tpl.ExecuteTemplate(w, "index.gohtml", posts)
  </code></pre>
  
  <p>but I couldn't display the <code>title</code> value in the view. Here is my code.</p>
  
  <p><strong>index.go</strong></p>
  
  <pre><code>package main
  
  import (
    "net/http"
    "fmt"
    "log"
    "database/sql"
    _ "github.com/go-sql-driver/mysql"
  )
  
  func index(w http.ResponseWriter, r *http.Request) {
    db, err := sql.Open("mysql", "root:****@/database")
    if err != nil {
      panic(err.Error())
    }
    defer db.Close()
  
    posts, err := db.Query("SELECT id, title FROM posts WHERE id = 1")
    var id int
    var title string
    for posts.Next() {
      err = posts.Scan(&amp;id, &amp;title)
      if err != nil {
        panic(err.Error())
      }
    }
  
    fmt.Println(posts)
  
    defer posts.Close()
  
    err = tpl.ExecuteTemplate(w, "index.gohtml", posts)
    if err != nil {
      log.Println(err)
    }
  }
  </code></pre>
  
  <p><strong>index.gohtml</strong></p>
  
  <pre><code>  &lt;h1&gt;Awesome Posts&lt;/h1&gt;
  
    {{$posts := .}}
    &lt;p&gt;{{$posts}}&lt;/p&gt;
  </code></pre>