Skip to content

Instantly share code, notes, and snippets.

@yukpiz yukpiz/でかい.go
Created Oct 1, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.