type queryConfInfoHandler struct {
ConfName string `json:"conf_name"`
}
For example, in the struct above, how do I know whether conf_name
is passed in the client's json? Because it is null when it is not passed in, but it is also possible that the client passed in a empty value.
One way I know is to change the type to *string
to determine whether the field is nil. I want to know if the gin framework has some built-in checking capabilities.
Comment From: r0ld3x
what do you get when you are doing c.BindJson(&queryConfInfo)
Comment From: zcfh
what do you get when you are doing
c.BindJson(&queryConfInfo)
conf_name == ""
Even if there is no conf_name in the requested json, conf_name
will still be initialized to zero value.
Comment From: r0ld3x
yes that's the limitation I see in go.
So I would try to use some validation and *string this is what we have I guess.