I am working on a patch restful request that the body json contain some omitted value while sending to golang. Since an unset value will lead the golang struct become default value. So I would like to know if there are any solution to deal with patch request omit data?
As I know, a basic type like string / int cannot be nullable in golang. there are different approach to deal with unset value patch request. For example:
-
using pointer to deal with null problem
type User struct { Name *string }
-
using nullable library
type User struct { Name sql.NullString }
using
map[string][]interface{}
to see if the value is set
Is there any better solution to deal with nullable value inside struct? since this 3 should be work around to deal with the nullable value.