Created
March 22, 2020 14:31
-
-
Save uurtech/48bf132df5975e1103028b7023673e46 to your computer and use it in GitHub Desktop.
Return Http Response and then Perform other tasks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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