NOTE helper is optional - https://github.com/AlekSi/pointer
models.User{
ID: 1,
Login: "Jonh",
Username: pointer.ToString("John Doe"),
CreatedAt: time.Date(2999, time.January, 1, 0, 0, 0, 0, time.UTC),
UpdatedAt: nil,
}
models.User{
ID: 1,
Login: "Jonh",
Username: dbr.NullString{NullString: sql.NullString{String: "Jonh Doe", Valid: true}},
CreatedAt: time.Date(2999, time.January, 1, 0, 0, 0, 0, time.UTC),
UpdatedAt: dbr.NullTime{},
}
models.User{
ID: 1,
Login: "Jonh",
Username: null.StringFrom("Jonh Doe"),
CreatedAt: time.Date(2999, time.January, 1, 0, 0, 0, 0, time.UTC),
UpdatedAt: null.TimeFromPtr(nil),
}
models.User{
ID: 1,
Login: "Jonh",
Username: ntypes.NewString("Jonh Doe"),
CreatedAt: time.Date(2999, time.January, 1, 0, 0, 0, 0, time.UTC),
// UpdatedAt: nil, // NOTE nullable time.Time is not supported
}
NOTE helper is optional - https://github.com/AlekSi/pointer
models.User{
ID: 1,
Login: "John",
Username: &"John Doe",
CreatedAt: 2999-01-01 00:00:00 UTC,
UpdatedAt: (*time.Time)(nil),
}
https://github.com/gocraft/dbr
models.User{
ID: 1,
Login: "John",
Username: dbr.NullString{
NullString: sql.NullString{
String: "John Doe",
Valid: true,
},
},
CreatedAt: 2999-01-01 00:00:00 UTC,
UpdatedAt: dbr.NullTime{
Time: 1-01-01 00:00:00 UTC,
Valid: false,
},
}
https://github.com/guregu/null
models.User{
ID: 1,
Login: "John",
Username: null.String{
NullString: sql.NullString{
String: "John Doe",
Valid: true,
},
},
CreatedAt: 2999-01-01 00:00:00 UTC,
UpdatedAt: null.Time{
Time: 1-01-01 00:00:00 UTC,
Valid: false,
},
}
https://github.com/piotrkowalczuk/ntypes
models.User{
ID: 1,
Login: "John",
Username: &ntypes.String{
String: "John Doe",
Valid: true,
},
CreatedAt: 2999-01-01 00:00:00 UTC,
// UpdatedAt: (*time.Time)(nil), // NOTE nullable time.Time is not supported
}