To make a HTTP delete request in Go, you can use the http
package that comes with the standard library. Here's an example:
main.go343 chars20 lines
In this example, we first create a http.NewRequest()
representing the HTTP DELETE request. We then add any necessary headers or request parameters to the request (in this case, we add none and create an empty body bytes.NewBuffer(nil)
).
Next, we use http.DefaultClient
to send our request with http.DefaultClient.Do()
. This returns a HTTP response object.
You can then use the http.Response
object to get any information you need from the response or check for any errors that may have occurred.
gistlibby LogSnag