struct-literal

The struct-literal join point matches struct literal expressions that create an instance of the named struct. In case of match being equal to value-only or any, the matched node will be of type CompositeLit, and in case of being pointer-only, it will be of type UnaryExpr (the node itself will be available in the {{ .X }} field). If field is specified, it only matches the value explicitly associated to the named field.

When using match: any, the struct literal may have its address immediately taken (&SomeType{/*...*/}), and associated advice must be carefully designed to avoid breaking this (for example, wrapping it in an immediately-invoked function expression makes it impossible to take the value’s address without first assigning it to a variable).

Examples

struct-literal:
    field: Handler
    type: net/http.Server
struct-literal:
    match: pointer-only
    type: net/http.Transport