jinzhu/gorm — pull request #91 by lame-nickname (2014-04-11 19:41:33+00:00)
Title: Add model inheritance via struct's anonymous fields

Hi,
I'd like to use anonymous struct fields as a way to create model inheritance.
Simple example:
``` go
type BasePost struct {
Id int64
Title string
Url string
}

type HNPost struct {
BasePost
Upvotes int32
Uploader HNUser
}

type EngadgetPost {
BasePost
ImageUrl string
Author EngadgetAuthor
}
````
which would end up being:
```` go
type HNPost struct {
Id int64
Title string
Url string
BasePost
Upvotes int32
Uploader HNUser
}

type EngadgetPost {
BasePost
ImageUrl string
Author EngadgetAuthor
Id int64
Title string
Url string
}
````
The current implementation creates ForeignKey in place of BasePost, in both EngadgetPost and HNPost. With this commit, this behavior is still there, but to use it one has to explicitly write:
```` go
type Model struct {
ForeignKeyType ForeignKeyType
}
````