title: Golang gRPC server-stream
body: <p>I have some issue with a gRPC server-stream on golang.
  I had no problem with one row, I just used the simple gRPC response for it. 
  But now I need to send a number of rows from my database and I can't finish my server-stream application.</p>
  
  <p>I just learn Golang and gRPC and this task a little bit difficult to me to solve this task now. And I will be very grateful if someone could help with this because not too many examples of this material on the web. 
  Or maybe you now where I can find an example, how to stream data from database using gRPC + golang. Thank you</p>
  
  <p>I have this code:</p>
  
  <pre><code>....
  
  type record struct {
  id       int
  lastname string
  }
  
  type server struct {
  
  }
  
  func (s *server) QueryData(city *pb.City, stream pb.GetDataStream_QueryDataServer) error {
  
  db, err := sql.Open("postgres", "postgres://adresspass")
  if err != nil {
      log.Fatal(err)
  }
  
  defer db.Close()
  
  rows, err := db.Query(`SELECT id, last_name FROM  person WHERE city=$1`, city.City)
  if err != nil {
      log.Fatal(err)
  }
  
  var rs = make([]record, 0)
  var rec record
  
  for rows.Next() {
      err = rows.Scan(&amp;rec.id, &amp;rec.lastname)
      if err != nil {
          return err
      }
  
      rs = append(rs, rec)
  }
  
  for _, onedata := range rs {
      if err := stream.Send(onedata); err != nil {
          return err
      }
  }
  return nil
  }
  
  ...
  </code></pre>