title: go build error "rows.Columns undefined (type *sql.Row has no field or method Columns)"
body: <p>I want to print multiple rows having multiple columns from my postgresql database using golang.while buildng the following code</p>
  <pre><code>package main
  
  import (
      &quot;database/sql&quot;
      &quot;fmt&quot;
      &quot;github.com/gin-gonic/gin&quot;
      _ &quot;github.com/lib/pq&quot;
      &quot;log&quot;
      &quot;runtime&quot;
  )
  
  func main() {
  
      runtime.GOMAXPROCS(runtime.NumCPU())
  
      db, err := sql.Open(&quot;postgres&quot;, &quot;dbname=sample_data user=postgres password=postgres sslmode=disable&quot;)
      defer db.Close()
      if err != nil {
          fmt.Println(&quot;error connecting to DB&quot;)
      }
      r := gin.Default()
      r.GET(&quot;/cin_display&quot;, func(c *gin.Context) {
          rows := db.QueryRow(&quot;SELECT cin FROM companies limit 1;&quot;)
  
          columns, _ := rows.Columns()
          count := len(columns)
          values := make([]interface{}, count)
          valuePtrs := make([]interface{}, count)
  
          for rows.Next() {
  
              for i, _ := range columns {
                  valuePtrs[i] = &amp;values[i]
              }
  
              rows.Scan(valuePtrs...)
  
              for i, col := range columns {
  
                  var v interface{}
  
                  val := values[i]
  
                  b, ok := val.([]byte)
  
                  if ok {
                      v = string(b)
                  } else {
                      v = val
                  }
  
                  fmt.Println(col, v)
              }
          }
  
      })
  }
  
  func Connect(connectionString string) *sql.DB {
      db, err := sql.Open(&quot;postgres&quot;, connectionString)
      if err != nil {
          log.Fatal(err)
      }
      return db
  }
  </code></pre>
  <p>I am getting the errors like</p>
  <blockquote>
  <p>rows.Columns undefined (type *sql.Row has no field or method Columns)</p>
  <p>rows.Next undefined (type *sql.Row has no field or method Next)</p>
  </blockquote>
  <p>how to solve this?</p>