(schemaFileName: string, packageName: string, generatedEncodingCode: string, wrapComments = false)
| 3028 | } |
| 3029 | |
| 3030 | function goGeneratedEncodingFileCode(schemaFileName: string, packageName: string, generatedEncodingCode: string, wrapComments = false): string { |
| 3031 | const lines: string[] = []; |
| 3032 | lines.push(...goDoNotEditHeader(schemaFileName)); |
| 3033 | lines.push(``); |
| 3034 | lines.push(`package ${packageName}`); |
| 3035 | lines.push(``); |
| 3036 | |
| 3037 | const imports = [`"encoding/json"`]; |
| 3038 | if (generatedEncodingCode.includes("errors.")) { |
| 3039 | imports.push(`"errors"`); |
| 3040 | } |
| 3041 | if (generatedEncodingCode.includes("time.Time")) { |
| 3042 | imports.push(`"time"`); |
| 3043 | } |
| 3044 | if (packageName !== "rpc" && generatedEncodingCode.includes("rpc.")) { |
| 3045 | imports.push(`"github.com/github/copilot-sdk/go/rpc"`); |
| 3046 | } |
| 3047 | lines.push(`import (`); |
| 3048 | for (const imp of imports) { |
| 3049 | lines.push(`\t${imp}`); |
| 3050 | } |
| 3051 | lines.push(`)`); |
| 3052 | lines.push(``); |
| 3053 | lines.push(generatedEncodingCode); |
| 3054 | |
| 3055 | const code = lines.join("\n"); |
| 3056 | return wrapComments ? wrapGeneratedGoComments(code) : code; |
| 3057 | } |
| 3058 | |
| 3059 | function generateGoRpcTypeCode(definitions: Record<string, JSONSchema7>, definitionCollections: DefinitionCollections): GoGeneratedTypeCode { |
| 3060 | const ctx: GoCodegenCtx = { |
no test coverage detected
searching dependent graphs…