generateMapValueReadIndented generates code to read a map value with custom indentation
(buf *bytes.Buffer, valueType types.Type, varName string, indent string)
| 1043 | |
| 1044 | // generateMapValueReadIndented generates code to read a map value with custom indentation |
| 1045 | func generateMapValueReadIndented(buf *bytes.Buffer, valueType types.Type, varName string, indent string) error { |
| 1046 | if basic, ok := valueType.Underlying().(*types.Basic); ok { |
| 1047 | switch basic.Kind() { |
| 1048 | case types.Int: |
| 1049 | fmt.Fprintf(buf, "%s%s = int(buf.ReadInt64(err))\n", indent, varName) |
| 1050 | case types.String: |
| 1051 | fmt.Fprintf(buf, "%s%s = ctx.ReadString()\n", indent, varName) |
| 1052 | default: |
| 1053 | return fmt.Errorf("unsupported map value type: %v", valueType) |
| 1054 | } |
| 1055 | return nil |
| 1056 | } |
| 1057 | fmt.Fprintf(buf, "%sctx.ReadValue(reflect.ValueOf(&%s).Elem(), fory.RefModeTracking, true)\n", indent, varName) |
| 1058 | return nil |
| 1059 | } |
no test coverage detected