This should get you started. https://play.golang.org/p/fKGkJPMToy
On Tuesday, 22 November 2016 21:58:31 UTC+11, iAdvice Edge wrote:
>
> i am new to Golang.
>
> can you just share some piece of code just to check each field in struct
> for empty or nil or zero value.
>
> On Tue, Nov 22, 2016 at 4:
i am new to Golang.
can you just share some piece of code just to check each field in struct
for empty or nil or zero value.
On Tue, Nov 22, 2016 at 4:19 PM, Dave Cheney wrote:
> If you want to write a general function you will need to use the reflect
> package, specifically reflect.Value.IsVal
If you want to write a general function you will need to use the reflect
package, specifically reflect.Value.IsValid to check each field to see if it
contains the zero value or not.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe
Hi Dave,
I need to create a common utility which checks whether the struct is empty
or not else i can throw error.
for example:
type Employee struct{
EmpId string
EmpName string
Department []String
Projects map[string]string
}
i need to check whether the object co