package main import ( "net/http" "github.com/emicklei/go-restful" ) func main() { // create a new RESTful web service service := new(restful.WebService) // define the basic structure for the endpoint service. Path("/hello"). Consumes(restful.MIME_JSON). Produces(restful.MIME_JSON) // define the response payload structure for the endpoint type greeting struct { Message string `json:"message"` } // define the handler function for the endpoint handler := func(request *restful.Request, response *restful.Response) { name := request.QueryParameter("name") if name == "" { name = "world" } g := greeting{ Message: "Hello, " + name + "!", } response.WriteEntity(g) } // bind the handler function to the GET method for the endpoint service.Route(service.GET("/{name}").To(handler)) // start the web service http.ListenAndServe(":8080", service) }This example defines a simple web service with a single endpoint that accepts a name parameter and returns a JSON response with a greeting message. The go-restful package is used to define the endpoint, handle the HTTP requests and responses, and start the web service. Package library: github.com/emicklei/go-restful