How to do it...

  1. Move to $GOPATH/src/my-first-beego-project/views and create dashboard.tpl and copy the following content:
<!DOCTYPE html><html>  <body>    <table border= "1" style="width:100%;">      {{range .employees}}      <tr>        <td>{{.Id}}</td>        <td>{{.FirstName}}</td>        <td>{{.LastName}}</td>      </tr>      {{end}}    </table>  </body></html>
  1. Move to $GOPATH/src/my-first-beego-project/controllers and edit firstcontroller.go to add the Dashboard handler, as follows:
package controllersimport "github.com/astaxie/beego"type FirstController struct {  beego.Controller}type Employee struct {  Id int `json:"id"`  FirstName string `json:"firstName"`  LastName string `json:"lastName"`}type Employees []Employeevar employees []Employeefunc init() {  employees = Employees  { Employee{Id: ...

Get Go Web Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.