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

Function goVariantMatchFunctionLines

scripts/codegen/go.ts:1712–1732  ·  view source on GitHub ↗
(
    variant: GoDiscriminatedUnionVariant,
    groupVariants: GoDiscriminatedUnionVariant[],
    discriminatorProp: string,
    ctx: GoCodegenCtx
)

Source from the content-addressed store, hash-verified

1710}
1711
1712function goVariantMatchFunctionLines(
1713 variant: GoDiscriminatedUnionVariant,
1714 groupVariants: GoDiscriminatedUnionVariant[],
1715 discriminatorProp: string,
1716 ctx: GoCodegenCtx
1717): string[] {
1718 const lines: string[] = [];
1719 lines.push(`func ${goVariantMatchFuncName(variant.typeName)}(data []byte) bool {`);
1720 const spec = goVariantTargetedMatchSpec(variant, groupVariants, discriminatorProp, ctx);
1721 if (spec.positiveTerms.length === 0 && spec.negativeExistsPaths.length === 0) {
1722 pushGoJSONSchemaMatchLines(lines, variant.schema, "data", ctx, "\t", "raw");
1723 lines.push(`\treturn true`);
1724 lines.push(`}`);
1725 return lines;
1726 }
1727
1728 const finalReturn = pushGoJSONTargetedMatchSpecLines(lines, "data", spec, "\t");
1729 lines.push(`\treturn ${finalReturn ?? "true"}`);
1730 lines.push(`}`);
1731 return lines;
1732}
1733
1734function goDiscriminatorMethodName(
1735 typeName: string,

Calls 5

goVariantMatchFuncNameFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…