MCPcopy Index your code
hub / github.com/coder/guts / IncludeCustom

Method IncludeCustom

convert.go:110–129  ·  view source on GitHub ↗

IncludeCustom takes in a remapping of golang types. Both the key and value of the map should be valid golang types. The key is the type to override, and the value is the new type. Typescript will be generated with the new type. Only named types can be overridden. Examples: "github.com/your/repo/pkg

(mappings map[GolangType]GolangType)

Source from the content-addressed store, hash-verified

108// "github.com/your/repo/pkg.ExampleType": "string"
109// "time.Time": "string"
110func (p *GoParser) IncludeCustom(mappings map[GolangType]GolangType) error {
111 for k, v := range mappings {
112 // Make sure it parses
113 _, err := parseExpression(v)
114 if err != nil {
115 return fmt.Errorf("failed to parse expression %s: %w", v, err)
116 }
117
118 v := v
119 p.typeOverrides[k] = func() bindings.ExpressionType {
120 exp, err := parseExpression(v)
121 if err != nil {
122 return ptr(bindings.KeywordUnknown)
123 }
124 return exp
125 }
126 }
127
128 return nil
129}
130
131// ExcludeCustom flags golang types to not be generated in the Typescript output.
132func (p *GoParser) ExcludeCustom(fqnames ...string) error {

Callers 3

ExampleNewGolangParserFunction · 0.80
TestGenerationFunction · 0.80
mainFunction · 0.80

Calls 2

parseExpressionFunction · 0.85
ptrFunction · 0.70

Tested by 2

ExampleNewGolangParserFunction · 0.64
TestGenerationFunction · 0.64