(x *ast.Ident, receiverType, fieldName string)
| 313 | } |
| 314 | |
| 315 | func (t *templateData) addSimpleValueIdent(x *ast.Ident, receiverType, fieldName string) { |
| 316 | getter := genIdentGetter(x, receiverType, fieldName) |
| 317 | getter.IsSimpleValue = true |
| 318 | logf("addSimpleValueIdent: Processing %q - fieldName=%q, getter.ZeroValue=%q, x.Obj=%#v", x.String(), fieldName, getter.ZeroValue, x.Obj) |
| 319 | if getter.ZeroValue == "nil" { |
| 320 | if x.Obj == nil { |
| 321 | switch x.String() { |
| 322 | case "any": // NOOP - leave as `nil` |
| 323 | default: |
| 324 | getter.ZeroValue = x.String() + "{}" |
| 325 | } |
| 326 | } else { |
| 327 | if ts, ok := x.Obj.Decl.(*ast.TypeSpec); ok { |
| 328 | logf("addSimpleValueIdent: Processing %q of type %T", x.String(), ts.Type) |
| 329 | switch xX := ts.Type.(type) { |
| 330 | case *ast.Ident: |
| 331 | logf("addSimpleValueIdent: Processing %q of type %T - zero value is %q", x.String(), ts.Type, getter.ZeroValue) |
| 332 | getter.ZeroValue = zeroValueOfIdent(xX) |
| 333 | case *ast.StructType: |
| 334 | getter.ZeroValue = x.String() + "{}" |
| 335 | logf("addSimpleValueIdent: Processing %q of type %T - zero value is %q", x.String(), ts.Type, getter.ZeroValue) |
| 336 | case *ast.InterfaceType, *ast.ArrayType: // NOOP - leave as `nil` |
| 337 | logf("addSimpleValueIdent: Processing %q of type %T - zero value is %q", x.String(), ts.Type, getter.ZeroValue) |
| 338 | default: |
| 339 | log.Fatalf("addSimpleValueIdent: unhandled case %T", xX) |
| 340 | } |
| 341 | } |
| 342 | } |
| 343 | } |
| 344 | t.Getters = append(t.Getters, getter) |
| 345 | } |
| 346 | |
| 347 | func (t *templateData) addIdent(x *ast.Ident, receiverType, fieldName string) { |
| 348 | getter := genIdentGetter(x, receiverType, fieldName) |
no test coverage detected