August 2021
Beginner
112 pages
1h 23m
English
| Puzzle 9 | Just in Time |
| | package main |
| | |
| | import ( |
| | "encoding/json" |
| | "fmt" |
| | "log" |
| | "time" |
| | ) |
| | |
| | func main() { |
| | t1 := time.Now() |
| | data, err := json.Marshal(t1) |
| | if err != nil { |
| | log.Fatal(err) |
| | } |
| | |
| | var t2 time.Time |
| | if err := json.Unmarshal(data, &t2); err != nil { |
| | log.Fatal(err) |
| | } |
| | fmt.Println(t1 == t2) |
| | } |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will print: false
You might expect this code to fail since there’s no time type in the JSON format, or you ...
Read now
Unlock full access