hasUnkeyedFields reports whether the composite literal has any positional (non-key/value) elements. The static check cannot reliably map positional fields without full type information, so such literals are rejected with a dedicated diagnostic rather than producing false "missing field" violations.
(cl *ast.CompositeLit)
| 191 | // fields without full type information, so such literals are rejected with a |
| 192 | // dedicated diagnostic rather than producing false "missing field" violations. |
| 193 | func hasUnkeyedFields(cl *ast.CompositeLit) bool { |
| 194 | for _, elt := range cl.Elts { |
| 195 | if _, ok := elt.(*ast.KeyValueExpr); !ok { |
| 196 | return true |
| 197 | } |
| 198 | } |
| 199 | return false |
| 200 | } |
| 201 | |
| 202 | // findFieldValue returns the value expression for the named keyed field of a |
| 203 | // composite literal, or nil if the field is absent. |