GetMetaType retrieves the type and package defined by the struct:field:type metadata if any.
(att *expr.AttributeExpr)
| 102 | // GetMetaType retrieves the type and package defined by the struct:field:type |
| 103 | // metadata if any. |
| 104 | func GetMetaType(att *expr.AttributeExpr) (typeName string, importS *ImportSpec) { |
| 105 | if att == nil { |
| 106 | return |
| 107 | } |
| 108 | if args, ok := att.Meta["struct:field:type"]; ok { |
| 109 | if len(args) > 0 { |
| 110 | typeName = args[0] |
| 111 | } |
| 112 | if len(args) > 1 { |
| 113 | importS = &ImportSpec{Path: args[1]} |
| 114 | } |
| 115 | if len(args) > 2 { |
| 116 | importS.Name = args[2] |
| 117 | } |
| 118 | } |
| 119 | return |
| 120 | } |
| 121 | |
| 122 | // GetMetaTypeImports parses the attribute for all user defined imports |
| 123 | func GetMetaTypeImports(att *expr.AttributeExpr) []*ImportSpec { |
no outgoing calls
no test coverage detected