MCPcopy Index your code
hub / github.com/wailsapp/wails / convertEnum

Method convertEnum

v2/internal/typescriptify/typescriptify.go:532–553  ·  view source on GitHub ↗
(depth int, typeOf reflect.Type, elements []enumElement)

Source from the content-addressed store, hash-verified

530}
531
532func (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
555func (t *TypeScriptify) getFieldOptions(structType reflect.Type, field reflect.StructField) TypeOptions {
556 // By default use options defined by tags:

Callers 1

ConvertMethod · 0.95

Calls 3

logfMethod · 0.95
nameTypeOfFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected