and dont know whether this way will make some mistake when it is zero value in struct.
is there some way to check isset() like php? not empty() check in php
thank you for your reply.
i see the function isEmptyValue, just like IsEmptyValue i write.
isEmptyValue is better.
i think there is no way to find out whether one variable is set or not.
because go will set one variable to zero value when defined automaticly.
len(array) == 0 or slice == nil this is easy to check.
a := 0
b := ""
this could not be checked.
If the zero value is not enough for what you need, then you need to explicitly keep track of when fields are set.
At that point I would really reconsider what I actually needed. For example, what harm is caused when a zero valued field is included or skipped? If it is just processing time or storage space, the cost of building a solution may be more than the resource use itself.
thank you for your patience.
i need to generate a query string with that struct.
the query string only contains the not null field in the struct value.
in the struct i given. the zero value checking is enough.