Re: [go-nuts] Re: Named or unnamed struct initialisation? What is best practice?

2017-07-11 Thread Rader Lei
they both have the same size, eg. following structs bar and bar2 both take 16 bytes memory on a x64 machine. package main import ( "fmt" "unsafe" ) type bar struct { A int _ bool } type bar2 struct { A int _ [0]byte } func main() { bar := bar{} bar2 := bar2{}

Re: [go-nuts] why received can be defined with/without pointer?

2017-05-07 Thread Rader Lei
if a method only defined for a pointer receiver, the compiler will add "*" before the caller silently. Why pointer receiver? Try to change the value of a member. You will know the difference. On Sunday, May 7, 2017 at 6:37:59 PM UTC+8, mhh...@gmail.com wrote: > > yes, sorry you scratched your h