tags in struct, conversion and comparability
This commit is contained in:
+8
-12
@@ -1,23 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Employee struct {
|
||||
Name string
|
||||
EID int
|
||||
Boss *Employee
|
||||
Hired time.Time
|
||||
type Response struct {
|
||||
Page int `json:"page"`
|
||||
Words []string `json:"words, omitempty"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
e := Employee{
|
||||
Name: "Zack",
|
||||
EID: 1,
|
||||
Hired: time.Now(),
|
||||
}
|
||||
r := &Response{Page: 1, Words: []string{"Leena", "Sami", "Sara", "Zaki"}}
|
||||
|
||||
fmt.Println(e.Name, e.Hired.Format(time.RFC1123))
|
||||
j, _ := json.MarshalIndent(r, "", " ")
|
||||
|
||||
fmt.Println(string(j))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user