I am still studying the Golang, and I want to ask something. Is it possible to do something like this and pass on to any other child in PMethod that extension of the parent structure?
type Parent struct{ PAttribute string } func (p *Parent) PMethod(c *Child){ fmt.Println("this is parent Attribute : " + p.PAttribute) fmt.Println("this is child Attribute : " + c.CAttribute) } type Child struct{ Parent CAttribute string } type Child2 struct{ Parent CAttribute string } func main(){ c := Child{ Parent{ "parent" }, "child", } c.PMethod(&c) c2 := Child2{ Parent{ "parent" }, "child", } c2.PMethod(&c2) }
thank
, , Go . . Go ( ), -. interfaces Go, Child and Child2, , ( ). , , , , Go. .
, , , , . - , . , , /, .
. - . Animal. , , , , Say() Animal, Say(), woofs Say(), .
Go Say() , Speaker(), - . , .
" " , , , , .
Source: https://habr.com/ru/post/1690576/More articles:SBT add projectID to logs in multiproject assembly - scalaCalling child method from parent implementation method in golang - compositionRare matrix as a field in a Chapel object - sparse-matrixThe object is still in the inactive version - sapGoogle Cloud Platform App Engine Node Flexible Ruby Instance sitting using 50% RAM - google-app-enginer gis: identify internal boundaries between polygons with sf - rCreate a domain with matrices in the Chapel - matrixr gis: find the boundaries between the polygons - rsynchronization of MS DB and CouchDB, CouchDB and PouchDb in C # - c #VBA - The most efficient method for filtering a collection / dictionary of user-defined classes by attribute - collectionsAll Articles