I often get down on how verbose Go is as compared to Ruby. However, this is an example where Go (and go-gin) is quite terse for what it’s doing:

chanStream := make(chan string)

go func() {
  defer close(chanStream)
  for i := 0; i < 10; i += 1 {
    chanStream <- fmt.Sprintf("msg %d", i)
c.Stream(func(w io.Writer) bool {
  if msg, ok := <-chanStream; ok {
    c.SSEvent("message", msg)
    return true
  return false

In this code we create a streaming HTTP response, such that the main server is not tied up while sending down data to the client. Pretty slick.