Created
October 1, 2018 08:28
-
-
Save yukpiz/c64c011f4166d6dc72267674544905cc to your computer and use it in GitHub Desktop.
This file contains 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
type User struct { | |
ID int | |
Profile Profile | |
Reservations []Reservation | |
Followers []User | |
Follows []User | |
WishList []Wish | |
CreatedAt time.Time | |
} | |
type Profile struct { | |
ID int | |
Name string | |
CreatedAt time.Time | |
} | |
type Reservation struct { | |
ID int | |
MerchantID int | |
StartDate time.Time | |
Memo string | |
CreatedAt time.Time | |
} | |
type Wish struct { | |
ID int | |
URL string | |
CreatedAt time.Time | |
} | |
func (user User) GetFollows() ([]User, error) { | |
return user.Follows, nil | |
} | |
func (user User) GetFollowers() ([]User, error) { | |
return user.Followers, nil | |
} | |
func main() { | |
user := User{ | |
ID: 1, | |
Profile: Profile{ | |
ID: 1, | |
Name: "yukpiz", | |
CreatedAt: time.Now(), | |
}, | |
Reservations: []Reservation{ | |
Reservation{ | |
ID: 1, | |
MerchantID: 111, | |
StartDate: time.Now(), | |
Memo: "memo", | |
CreatedAt: time.Now(), | |
}, | |
}, | |
Followers: []User{ | |
User{ | |
ID: 2, | |
Profile: Profile{ | |
ID: 2, | |
Name: "moriyuki", | |
CreatedAt: time.Now(), | |
}, | |
Reservations: []Reservation{ | |
Reservation{ | |
ID: 2, | |
MerchantID: 111, | |
StartDate: time.Now(), | |
Memo: "memo", | |
CreatedAt: time.Now(), | |
}, | |
}, | |
Followers: []User{}, | |
Follows: []User{}, | |
WishList: []Wish{ | |
Wish{ | |
ID: 1, | |
URL: "https://example.com/1/", | |
CreatedAt: time.Now(), | |
}, | |
Wish{ | |
ID: 2, | |
URL: "https://example.com/2/", | |
CreatedAt: time.Now(), | |
}, | |
Wish{ | |
ID: 3, | |
URL: "https://example.com/3/", | |
CreatedAt: time.Now(), | |
}, | |
}, | |
}, | |
}, | |
Follows: []User{ | |
User{ | |
ID: 2, | |
Profile: Profile{ | |
ID: 2, | |
Name: "moriyuki", | |
CreatedAt: time.Now(), | |
}, | |
Reservations: []Reservation{ | |
Reservation{ | |
ID: 2, | |
MerchantID: 111, | |
StartDate: time.Now(), | |
Memo: "memo", | |
CreatedAt: time.Now(), | |
}, | |
}, | |
Followers: []User{}, | |
Follows: []User{}, | |
WishList: []Wish{ | |
Wish{ | |
ID: 1, | |
URL: "https://example.com/1/", | |
CreatedAt: time.Now(), | |
}, | |
Wish{ | |
ID: 2, | |
URL: "https://example.com/2/", | |
CreatedAt: time.Now(), | |
}, | |
Wish{ | |
ID: 3, | |
URL: "https://example.com/3/", | |
CreatedAt: time.Now(), | |
}, | |
}, | |
}, | |
}, | |
WishList: []Wish{ | |
Wish{ | |
ID: 1, | |
URL: "https://example.com/1/", | |
CreatedAt: time.Now(), | |
}, | |
Wish{ | |
ID: 2, | |
URL: "https://example.com/2/", | |
CreatedAt: time.Now(), | |
}, | |
Wish{ | |
ID: 3, | |
URL: "https://example.com/3/", | |
CreatedAt: time.Now(), | |
}, | |
}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment