MCPcopy Create free account
hub / github.com/goadesign/goa / GoNativeTypeName

Function GoNativeTypeName

codegen/types.go:13–42  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

11// GoNativeTypeName returns the Go built-in type corresponding to the given
12// primitive type. GoNativeType panics if t is not a primitive type.
13func 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.
45func AttributeTags(_, att *expr.AttributeExpr) string {

Callers 9

goTypeDefFunction · 0.92
transformObjectFunction · 0.92
primitiveAliasGoTypeFunction · 0.92
FieldLoadCodeFunction · 0.92
cli.goFile · 0.92
TestGoNativeTypeNameFunction · 0.85
transformObjectFunction · 0.85
GoFullTypeNameMethod · 0.85

Calls 1

KindMethod · 0.65

Tested by 1

TestGoNativeTypeNameFunction · 0.68