November 2017
Intermediate to advanced
670 pages
17h 35m
English
Let's have a look at src/functor/car.go:
package functorimport ( "fmt" "strings")type ( Car struct { Make string `json:"make"` Model string `json:"model"` })
It's good practice to define our types at the top. Putting them in a type block helps to keep our code clean and tidy. Another good practice is to add JSON annotations to each field of a struct to enable easy (un)marshalling of JSON into our Car struct.