diff --git a/packages/jsii-pacmak/lib/targets/go.ts b/packages/jsii-pacmak/lib/targets/go.ts index 41fd2297c7..3373341811 100644 --- a/packages/jsii-pacmak/lib/targets/go.ts +++ b/packages/jsii-pacmak/lib/targets/go.ts @@ -54,7 +54,13 @@ export class Golang extends Target { ); return Promise.reject(e); } - await go('build', ['-modfile', localGoMod.path, './...'], { cwd: pkgDir }); + + if (process.env.JSII_BUILD_GO) { + // This step is taken to ensure that the generated code is compilable + await go('build', ['-modfile', localGoMod.path, './...'], { + cwd: pkgDir, + }); + } // delete local.go.mod and local.go.sum from the output directory so it doesn't get published const localGoSum = `${path.basename(localGoMod.path, '.mod')}.sum`;