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 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: ...

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