Puzzle 11 Explanation: Go Log
Understand the concept of log in Go.
We'll cover the following...
Try it yourself
Try executing the code below to see the result.
Press + to interact
package mainimport ("fmt""time")// Log is a log messagetype Log struct {Message stringtime.Time}func main() {ts := time.Date(2009, 11, 10, 0, 0, 0, 0, time.UTC)log := Log{"Hello", ts}fmt.Printf("%v\n", log)}
Explanation
The %v
verb will print all the struct fields.
Press + to interact
package mainimport ("fmt")// Point is a 2D pointtype Point struct {X intY int}func main() {p := Point{1, 2}fmt.Printf("%v\n", p) // {1 2}}
We’d expect the teaser code to print{Hello 2009-11-10 00:00:00 +0000 UTC}
. ...