Skip to content

Instantly share code, notes, and snippets.

@wuriyanto48
Created October 11, 2018 23:57
Show Gist options
  • Select an option

  • Save wuriyanto48/abd50bf9bef6d36fa30e2a41289cb810 to your computer and use it in GitHub Desktop.

Select an option

Save wuriyanto48/abd50bf9bef6d36fa30e2a41289cb810 to your computer and use it in GitHub Desktop.
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