Skip to content

Instantly share code, notes, and snippets.

@uurtech
Created March 22, 2020 14:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uurtech/48bf132df5975e1103028b7023673e46 to your computer and use it in GitHub Desktop.
Save uurtech/48bf132df5975e1103028b7023673e46 to your computer and use it in GitHub Desktop.
Return Http Response and then Perform other tasks
package main
import (
"fmt"
"net/http"
"sync"
"time"
)
func ping(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
}
func search(w http.ResponseWriter, r *http.Request) {
wg := &sync.WaitGroup{}
go writer(wg)
w.Write([]byte("hello"))
wg.Wait()
}
func writer(wg *sync.WaitGroup) {
wg.Add(1)
for i := 0; i < 10; i++ {
fmt.Print("olaylar\n")
time.Sleep(1 * time.Second)
}
wg.Done()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment