[go-nuts] Re: How do you mitigate against nil pointer dereference

2017-01-13 Thread mailteety
Hello, Thanks for the response. The Major Issue is that am getting the Data from *json *and its inconsistent. Regards Teety On Friday, 13 January 2017 14:41:02 UTC+1, mhh...@gmail.com wrote: > > Hi, > > some simple leads, > > Use one line initialization of Person > p := {Attr:{}} > > Enhance

Re: [go-nuts] Re: How do you mitigate against nil pointer dereference

2017-01-13 Thread Henrik Johansson
Expose properties as methods and do the check in the method can make the caller use easier. On Fri, Jan 13, 2017, 14:41 wrote: > Hi, > > some simple leads, > > Use one line initialization of Person > p := {Attr:{}} > > Enhance the if conditions statement > if p.Attr !=

[go-nuts] Re: How do you mitigate against nil pointer dereference

2017-01-13 Thread mhhcbon
Hi, some simple leads, Use one line initialization of Person p := {Attr:{}} Enhance the if conditions statement if p.Attr != nil && p.Attr.Age < 10 { fmt.Println("Too Young") } Use a Person constructor func NewPerson() { return {Attr:{}} } I, too, dislike that default