GoNativeTypeName returns the Go built-in type corresponding to the given primitive type. GoNativeType panics if t is not a primitive type.
(t expr.DataType)
| 11 | // GoNativeTypeName returns the Go built-in type corresponding to the given |
| 12 | // primitive type. GoNativeType panics if t is not a primitive type. |
| 13 | func GoNativeTypeName(t expr.DataType) string { |
| 14 | switch t.Kind() { |
| 15 | case expr.BooleanKind: |
| 16 | return "bool" |
| 17 | case expr.IntKind: |
| 18 | return "int" |
| 19 | case expr.Int32Kind: |
| 20 | return "int32" |
| 21 | case expr.Int64Kind: |
| 22 | return "int64" |
| 23 | case expr.UIntKind: |
| 24 | return "uint" |
| 25 | case expr.UInt32Kind: |
| 26 | return "uint32" |
| 27 | case expr.UInt64Kind: |
| 28 | return "uint64" |
| 29 | case expr.Float32Kind: |
| 30 | return "float32" |
| 31 | case expr.Float64Kind: |
| 32 | return "float64" |
| 33 | case expr.StringKind: |
| 34 | return "string" |
| 35 | case expr.BytesKind: |
| 36 | return "[]byte" |
| 37 | case expr.AnyKind: |
| 38 | return "any" |
| 39 | default: |
| 40 | panic(fmt.Sprintf("cannot compute native Go type for %T", t)) // bug |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | // AttributeTags computes the struct field tags from its metadata if any. |
| 45 | func AttributeTags(_, att *expr.AttributeExpr) string { |