(depth int, typeOf reflect.Type, elements []enumElement)
| 530 | } |
| 531 | |
| 532 | func (t *TypeScriptify) convertEnum(depth int, typeOf reflect.Type, elements []enumElement) (string, error) { |
| 533 | t.logf(depth, "Converting enum %s", typeOf.String()) |
| 534 | if _, found := t.alreadyConverted[typeOf.String()]; found { // Already converted |
| 535 | return "", nil |
| 536 | } |
| 537 | t.alreadyConverted[typeOf.String()] = true |
| 538 | |
| 539 | entityName := t.Prefix + nameTypeOf(typeOf) + t.Suffix |
| 540 | result := "enum " + entityName + " {\n" |
| 541 | |
| 542 | for _, val := range elements { |
| 543 | result += fmt.Sprintf("%s%s = %#v,\n", t.Indent, val.name, val.value) |
| 544 | } |
| 545 | |
| 546 | result += "}" |
| 547 | |
| 548 | if !t.DontExport { |
| 549 | result = "export " + result |
| 550 | } |
| 551 | |
| 552 | return result, nil |
| 553 | } |
| 554 | |
| 555 | func (t *TypeScriptify) getFieldOptions(structType reflect.Type, field reflect.StructField) TypeOptions { |
| 556 | // By default use options defined by tags: |
no test coverage detected