如何将golang之类的http响应状态文本更改为200 OK到200 {Custom text}

I want to change the response text for the given status code in GO. how to do it.

Currently the status text for some popular status code is like this: 200 -> OK 404 -> NOT FOUND 201 -> CREATED

I want to change the text with my message like 200 -> {MY CUSTOM MESSAGE}

If you really want to change the response, you could use net package of golang and implement your own HTTP-like protocol instead of using net/http.

The Reason-Phrase in the Status-Line is fixed and you should not change it. Really, Don't. Stick to the official format, e.g.

HTTP/1.1 200 OK

But this is independent from the Body you send (where appropriate). Nothing prevents you from sending a body like this

http.Error(w, "Good boy! Well done!", http.StatusOK)

But again: changing the status line is a Bad Idea.