Creating new values

The reflect package allows us also to create new values using types. There are several functions that allow us to create a value:

The following code shows how to create new values in a couple of different ways:

func main() {
t := reflect.TypeOf(int64(100))
// zero value
fmt.Printf("%#v\n", reflect.Zero(t))
// pointer to int
fmt.Printf("%#v\n", reflect.New(t))
}

A full example is available here: https://play.golang.org/p/wCTILSK1F1C.