Skip to content

Instantly share code, notes, and snippets.

@JakeTheCorn
Created July 14, 2018 03:23
Show Gist options
  • Save JakeTheCorn/f0d6b3d83326eb49f8d32d61756d2755 to your computer and use it in GitHub Desktop.
Save JakeTheCorn/f0d6b3d83326eb49f8d32d61756d2755 to your computer and use it in GitHub Desktop.
DELETE example in Go
func destroyFriend() {
resourceURL := "http://rest.learncode.academy/api/johnbob/friends/5b496c3b79f71d000f953fac"
req, err := http.NewRequest("DELETE", resourceURL, nil)
if err != nil {
panic(err)
}
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment