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. Create a new project and skeleton application by executing the following command:
$ ng new angularjs-client
  1. Move to the angularjs-client directory and create server.go by executing the following command:
$ cd angularjs-client && touch server.go
  1. Copy the following code to server.go
package mainimport (  "encoding/json"  "log"  "net/http"  "github.com/gorilla/mux")const (  CONN_HOST = "localhost"  CONN_PORT = "8080")type Route struct {  Name string  Method string  Pattern string  HandlerFunc http.HandlerFunc}type Routes []Routevar routes = Routes{  Route  {    "getEmployees",    "GET",    "/employees",    getEmployees,  },  Route  {    "addEmployee",    "POST",    "/employee/add",    addEmployee,  },}type Employee struct {  Id string `json:"id"` FirstName string ...

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