import ( "github.com/goadesign/goa" ) // Define a struct for the new controller type MyController struct { *goa.Controller } // Use the Service NewController to create a new instance of the controller func NewMyController(service *goa.Service) *MyController { return &MyController{Controller: service.NewController("MyController")} }
type MyController struct { *goa.Controller } func (c *MyController) Get(ctx *app.GetMyContext) error { return ctx.OK([]byte("Hello World!")) } func NewMyController(service *goa.Service) *MyController { return &MyController{Controller: service.NewController("MyController")} }In this example, we define a new method in the MyController struct called Get, which returns an HTTP response with the string "Hello World!". We then use the Service NewController method to create a new instance of this controller, which can be used to handle HTTP requests.