(
variant: GoDiscriminatedUnionVariant,
groupVariants: GoDiscriminatedUnionVariant[],
discriminatorProp: string,
ctx: GoCodegenCtx
)
| 1710 | } |
| 1711 | |
| 1712 | function 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 | |
| 1734 | function goDiscriminatorMethodName( |
| 1735 | typeName: string, |
no test coverage detected
searching dependent graphs…