Last active
May 31, 2019 15:48
-
-
Save Duncanian/f3ca28e6bbd8796471edc10295e18fc0 to your computer and use it in GitHub Desktop.
Handling the endpoint for deleting an event in go-rest-api
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
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