func handler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) }
func handler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotFound) fmt.Fprintf(w, "404 Page Not Found") }In this example, the HTTP status code 404 (Not Found) is written to the response using the WriteHeader function. Additionally, a custom error message is written to the response using the fmt.Fprintf function. This tells the client that the requested resource cannot be found on the server. Both of the examples above belong to the net/http package library in Go language.