[go-nuts] Re: Struct overloading method issue

2017-09-01 Thread BeaT Adrian
I solved it for now using composition and Constructors func NewA() { r := A{} r.private = privateForA } func NewB(){ r := B{} r.private = privateForB } I saw using constructors in a few builtin packages so I guess is ok. On Friday, September 1, 2017 at 5:50:52 PM UTC+3, BeaT Adrian

[go-nuts] Struct overloading method issue

2017-09-01 Thread BeaT Adrian
Hello, I ran into a strange scenario and I wanted to know if there is a better solution for it type A struct{} func (a *A) private() {} func (a *A) Public() { a.private() } type B struct {A} func (b *B) private() {} bi := B{} b.Public() //calls the A.Private I just want to rewrite a sma

[go-nuts] Re: can list.List.Push* or Get return nil?

2017-08-30 Thread BeaT Adrian
esday, August 29, 2017 at 8:24:58 PM UTC+3, Egon wrote: > > Is there a reason you are using `container/list`, in most cases it's the > wrong solution. Slices in most cases are faster and use less resources and > easier to work with. > > + Egon > > On Tuesday, 29 Augus

[go-nuts] Re: can list.List.Push* or Get return nil?

2017-08-29 Thread BeaT Adrian
Thanks, my bad, for Back() and Front() is obvious, returns nil when there are no elements left. But I don't see how a Push*() can return nil, it always return an Element. If I push a nil it will return an Element with value=nil. On Tuesday, August 29, 2017 at 7:27:31 AM UTC+3, snmed wrote: > >

[go-nuts] can list.List.Push* or Get return nil?

2017-08-28 Thread BeaT Adrian
Hello, I just started to learn golang and I have a small dillema. My programming is too defensive OR how can I replicate this scenario (for my test coverage sake) list = list.New() element := list.PushBack(item) if element == nil { //don't know how this can happen, just being defensive return