Skip to content

Instantly share code, notes, and snippets.

@Duncanian
Last active May 31, 2019 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Duncanian/f3ca28e6bbd8796471edc10295e18fc0 to your computer and use it in GitHub Desktop.
Save Duncanian/f3ca28e6bbd8796471edc10295e18fc0 to your computer and use it in GitHub Desktop.
Handling the endpoint for deleting an event in go-rest-api
func deleteEvent(w http.ResponseWriter, r *http.Request) {
eventID := mux.Vars(r)["id"]
for i, singleEvent := range events {
if singleEvent.ID == eventID {
events = append(events[:i], events[i+1:]...)
fmt.Fprintf(w, "The event with ID %v has been deleted successfully", eventID)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment