Created
October 11, 2018 23:57
-
-
Save wuriyanto48/abd50bf9bef6d36fa30e2a41289cb810 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "encoding/json" | |
| "time" | |
| ) | |
| type Person struct { | |
| ID string `json:"id"` | |
| Name string `json:"name"` | |
| BaseModel | |
| } | |
| type BaseModel struct { | |
| Created time.Time `json:"created"` | |
| } | |
| func main() { | |
| //p := Person{ID: "1", Name: "Wury", BaseModel: BaseModel{Created: time.Now()}} | |
| var p Person | |
| p.ID = "1" | |
| p.Name = "Wury" | |
| p.Created = time.Now() | |
| b, _ := json.Marshal(p) | |
| fmt.Println(string(b)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment