How to do it...

These steps cover writing and running your application:

  1. From your terminal/console application, create and navigate to the chapter3/nulls directory.
  2. Copy tests from https://github.com/agtorre/go-cookbook/tree/master/chapter3/nulls or use this as an exercise to write some of your own code.
  3. Create a file called base.go with the following contents:
        package nulls        import (            "encoding/json"            "fmt"        )        // json that has name but not age        const (            jsonBlob = `{"name": "Aaron"}`            fulljsonBlob = `{"name":"Aaron", "age":0}`        )        // Example is a basic struct with age        // and name fields        type Example struct {            Age int `json:"age,omitempty"`            Name string `json:"name"`        }        // BaseEncoding shows encoding and        // decoding with normal types func BaseEncoding() ...

Get Go 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.