QualifiedTypeName returns the qualified type name for the given data type. The qualified type name includes the name of the type of the elements of array or map types. This is useful in reporting types in error messages, examples of qualified type names: "array " "map " "ma
(t DataType)
| 682 | // "map<string, string>" |
| 683 | // "map<string, array<int32>>" |
| 684 | func QualifiedTypeName(t DataType) string { |
| 685 | switch t.Kind() { |
| 686 | case ArrayKind: |
| 687 | a := t.(*Array) |
| 688 | return fmt.Sprintf("%s<%s>", |
| 689 | t.Name(), |
| 690 | QualifiedTypeName(a.ElemType.Type), |
| 691 | ) |
| 692 | case MapKind: |
| 693 | h := t.(*Map) |
| 694 | return fmt.Sprintf("%s<%s, %s>", |
| 695 | t.Name(), |
| 696 | QualifiedTypeName(h.KeyType.Type), |
| 697 | QualifiedTypeName(h.ElemType.Type), |
| 698 | ) |
| 699 | } |
| 700 | return t.Name() |
| 701 | } |
| 702 | |
| 703 | // toReflectType converts the DataType to reflect.Type. |
| 704 | func toReflectType(dtype DataType) reflect.Type { |