Last active
August 29, 2015 14:16
-
-
Save jochasinga/52a7c7c86507c91e4ab3 to your computer and use it in GitHub Desktop.
Simple struct models for a blog post
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 "time" | |
// User | |
type User struct { | |
Id int `json:"id"` | |
Username string `json:"username"` | |
Email string `json:"email"` | |
} | |
// Comment | |
type Comment struct { | |
Id int `json:"id"` | |
User User `json:"user"` | |
Text string `json:"text"` | |
Timestamp time.Time `json:"timestamp"` | |
} | |
// Post | |
type Post struct { | |
Id int `json:"id"` | |
User User `json:"user"` | |
Topic string `json:"topic"` | |
Text string `json:"text"` | |
Comment Comment `json:"comment"` | |
Timestamp time.Time `json:"timestamp"` | |
} | |
type Posts []Post | |
type Comments []Comment | |
type Users []User |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment