Skip to content

Instantly share code, notes, and snippets.

@dejanvasic85
Created October 4, 2019 11:47
Show Gist options
  • Select an option

  • Save dejanvasic85/28e9a1bd856f7ec1bd17689f56d3d688 to your computer and use it in GitHub Desktop.

Select an option

Save dejanvasic85/28e9a1bd856f7ec1bd17689f56d3d688 to your computer and use it in GitHub Desktop.
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