O'Reilly logo

Go Web Development Cookbook by Arpit Aggarwal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works…

Once the command has executed successfully, the web application will run on the default Beego port 8080.

Next, executing a GET request from the command line will give you a list of all the employees:

$ curl -X GET http://localhost:8080/employees[  {    "id": 1,    "firstName": "Foo",    "lastName": "Bar"  },  {    "id": 2,    "firstName": "Baz",    "lastName": "Qux"  }]

Let’s understand the program we have written:

  • import “github.com/astaxie/beego": Here, we imported Beego.
  • type FirstController struct { beego.Controller }: Here, we defined the FirstController struct type, which contains an anonymous struct field of type beego.Controller because of which FirstController automatically acquires all the methods of beego.Controller.
  • func (this *FirstController) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required