On Thursday, 2 January 2020 15:01:15 UTC+9, Glen Huang wrote:
>
> @Ben
>
> My real world use case is that I have these types that dealing with user
> signing up/loging in
>
> type LogIn struct {
> Name string
> Password string
> }
>
> type SignUp struct {
> Name string
> Password string
@Ben
My real world use case is that I have these types that dealing with user
signing up/loging in
type LogIn struct {
Name string
Password string
}
type SignUp struct {
Name string
Password string
Gender string
}
I was hoping that I cloud embed LogIn inside SignUp, to eliminate d
On Tuesday, 31 December 2019 19:21:07 UTC+9, Glen Huang wrote:
>
> I want to unmarshal a struct that contains embedded structs:
>
> type Parent struct {
> Child
> P int
> }
>
>
> type Child struct {
> Grandchild
> C int
> }
>
>
> type Grandchild struct {
> G int
> }
>
> The problem is that
1. I think it's not correct to use terms "parent" and "child", as Go is not
an OOP language.
2. Please note that what you call a Child is actually a Parent, and vice
versa. This puts a lot of confusion.
3. Embedding struct will get methods of embedded (depending on whether
they've been defined f
After thinking more about it, I start to feel that maybe using embedded
structs is generally a bad idea with dealing with json? Is the correct
solution here to use explicit fields?
BTW, happy New Year everyone.
On Tuesday, December 31, 2019 at 6:21:07 PM UTC+8, Glen Huang wrote:
>
> I want to u