Here is a sample code:
package main import ( "fmt" ) type A struct { Name string } func (this *A) demo(tag string) { fmt.Printf("%#v\n", this) fmt.Println(tag) } func main() { var ele A ele.demo("ele are called") ele2 := A{} ele2.demo("ele2 are called") }
Execution Results:
&main.A{Name:""} ele are called &main.A{Name:""} ele2 are called
It looks like the same in var ele A and ele2 := A{}
Thus, the value of struct Zero is not nil , but a structure in which all properties are initialized values โโof Zero. Is the assumption correct?
If the assumption is true, then the nature of var ele A and ele2 := A{} same, right?
struct go
soapbar
source share