[go-nuts] Re: slice of pointer of struct vs slice of struct

2017-10-20 Thread Feby Tanzil
hmm, suppose I have struct X that have 50 attributes that represent 50 cols 
in db, struct Y 4 attributes, 4 cols

and I have :

func FindX() *X {}
func FindXs() []*X {}

func FindY() *Y {}
func FindYs() []*Y {}

I don't care about mutable, since this is only a getter func, or should I 
care? 
since I already queried to db, and the caller is free to do anything to 
that result
because X is large, then I prefer pointer,
and then for the sake of consistency, 
others (e.g. struct Y) I set them too as pointer, 
regardless other structs may be a small struct
no receiver func yet for those structs
no modifying, mostly just reading the result

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: slice of pointer of struct vs slice of struct

2017-10-20 Thread Feby Tanzil
so if I have like 50 attributes then pointer is preferable then
How big is big? I took 
from https://github.com/golang/go/wiki/CodeReviewComments for receiver, is 
this applicable for this too?

Assume it's equivalent to passing all its elements as arguments to the 
> method. If that feels too large, it's also too large for the receiver.
>

On Friday, 20 October 2017 12:25:27 UTC+7, Feby Tanzil wrote:
>
> Hi,
>
> I got vague answers in the internet over this.
> Which is better & preferable in Go?
>
> type T struct {
>  // some attributes
>  ...
> }
>
> func a() []T {
>
> }
>
> func b() []*T {
>
> }
>
>
>
> Thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] slice of pointer of struct vs slice of struct

2017-10-19 Thread Feby Tanzil
Hi,

I got vague answers in the internet over this.
Which is better & preferable in Go?

type T struct {
 // some attributes
 ...
}

func a() []T {

}

func b() []*T {

}



Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.