MCPcopy Index your code
hub / github.com/github/copilot-sdk / goPrimitiveUnionVariants

Function goPrimitiveUnionVariants

scripts/codegen/go.ts:2532–2553  ·  view source on GitHub ↗
(typeName: string, schema: JSONSchema7, ctx: GoCodegenCtx)

Source from the content-addressed store, hash-verified

2530}
2531
2532function goPrimitiveUnionVariants(typeName: string, schema: JSONSchema7, ctx: GoCodegenCtx): GoPrimitiveUnionVariant[] | undefined {
2533 const members = goNonNullUnionMembers(schema);
2534 if (members.length === 0) return undefined;
2535
2536 const variants: GoPrimitiveUnionVariant[] = [];
2537 const seenTypeNames = new Set<string>();
2538 for (const member of members) {
2539 const valueName = goPrimitiveUnionValueName(member, ctx);
2540 const goType = goPrimitiveUnionGoType(member, ctx);
2541 if (!valueName || !goType) return undefined;
2542
2543 const variantTypeName = goPrimitiveUnionVariantTypeName(typeName, valueName);
2544 if (seenTypeNames.has(variantTypeName)) return undefined;
2545 seenTypeNames.add(variantTypeName);
2546 variants.push({
2547 typeName: variantTypeName,
2548 goType,
2549 });
2550 }
2551
2552 return variants;
2553}
2554
2555function emitGoPrimitiveUnionInterface(typeName: string, schema: JSONSchema7, ctx: GoCodegenCtx, variants?: GoPrimitiveUnionVariant[]): boolean {
2556 if (ctx.generatedNames.has(typeName)) return true;

Callers 2

planGoUnionFunction · 0.85

Calls 6

goNonNullUnionMembersFunction · 0.85
goPrimitiveUnionGoTypeFunction · 0.85
addMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…