diff --git a/packages/jsii-pacmak/lib/targets/go.ts b/packages/jsii-pacmak/lib/targets/go.ts index a6597a25cf..7ea9980332 100644 --- a/packages/jsii-pacmak/lib/targets/go.ts +++ b/packages/jsii-pacmak/lib/targets/go.ts @@ -40,7 +40,9 @@ export class Golang extends Target { // write `local.go.mod` with "replace" directives for local modules const localGoMod = await this.writeLocalGoMod(pkgDir); - // run `go build` with local.go.mod + // run `go build` with local.go.mod, go 1.16 requires that we download + // modules explicit so go.sum is updated. + await go('mod', ['download', '-modfile', localGoMod], { cwd: pkgDir }); await go('build', ['-modfile', localGoMod], { cwd: pkgDir }); // delete local.go.mod and local.go.sum from the output directory so it doesn't get published @@ -229,5 +231,11 @@ function tryFindLocalRuntime(): */ async function go(command: string, args: string[], options: { cwd: string }) { const { cwd } = options; - return shell('go', [command, ...args], { cwd }); + return shell('go', [command, ...args], { + cwd, + env: { + // disable the use of sumdb to reduce eventual consistency issues when new modules are published + GOSUMDB: 'off', + }, + }); }