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