Re: [go-nuts] Re: Reflect Struct Comparison

2016-11-22 Thread Dave Cheney
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:

Re: [go-nuts] Re: Reflect Struct Comparison

2016-11-22 Thread iAdvice Edge
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

Re: [go-nuts] Re: Reflect Struct Comparison

2016-11-22 Thread Dave Cheney
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

Re: [go-nuts] Re: Reflect Struct Comparison

2016-11-22 Thread iAdvice Edge
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

[go-nuts] Re: Reflect Struct Comparison

2016-11-22 Thread Dave Cheney
Please do not reopen to a four year old thread. Instead please start a new thread describing the problem you have, what you tried, and what happened when you tried. Thanks -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from thi

[go-nuts] Re: Reflect Struct Comparison

2016-11-21 Thread iadviceedge
can someone attach the improved and efficient code? On Friday, March 30, 2012 at 5:29:52 PM UTC+5:30, Luke Mauldin wrote: > > I have the the task of comparing two structs (of the same type) for > equality and returning the field level differences. One of the > restrictions is that I only have t