You can create a HTTP server in Go by using the net/http package. Here's an example that shows how to create a server with a specific route and a specific status code:
main.go420 chars23 linesIn this example, we define a handler function for the /hello route. Inside the handler, we set the status code to http.StatusOK before writing the response body using fmt.Fprint(). Finally, we start the server by calling http.ListenAndServe() and passing in the handler function.
gistlibby LogSnag