From GoQuery:
type Document struct {
*Selection
Url *url.URL
// contains filtered or unexported fields
}
I want to get *Selection
pointer from a *Document
variable:
doc, e := goquery.NewDocument("http://www.gemalto.com/companyinfo/careers/")
var sel *goquery.Selection = doc // error!
sel = doc.(*goquery.Selection) // also error!
The unqualified type name acts as the field name
var sel *goquery.Selection = doc.Selection
See the section on Struct Types for details:
A field declared with a type but no explicit field name is an anonymous field, also called an embedded field or an embedding of the type in the struct. An embedded type must be specified as a type name
T
or as a pointer to a non-interface type name*T
, andT
itself may not be a pointer type. The unqualified type name acts as the field name.