Created
October 4, 2019 11:47
-
-
Save dejanvasic85/28e9a1bd856f7ec1bd17689f56d3d688 to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
| "sync" | |
| "github.com/dghubble/sling" | |
| ) | |
| func main() { | |
| var wg sync.WaitGroup | |
| client := sling.New().Base("http://localhost:3000") | |
| for i := 0; i < 5; i++ { | |
| wg.Add(1) | |
| go Call(&wg, client, "/booking/step/1") | |
| } | |
| fmt.Println("Waiting to finish") | |
| wg.Wait() | |
| fmt.Println("Waiting to finish") | |
| } | |
| // Call will make the calls | |
| func Call(wg *sync.WaitGroup, cl *sling.Sling, url string) { | |
| defer wg.Done() | |
| data := struct { | |
| CategoryID string `json:categoryId` | |
| }{ | |
| "1", | |
| } | |
| resp, err := cl.Post(url).BodyJSON(data).ReceiveSuccess(nil) | |
| if err != nil { | |
| panic(err) | |
| } | |
| fmt.Printf("And the RESP : %d", resp.StatusCode) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment