Skip to content

Commit

Permalink
fix(pacmak/go): missing go.sum entry (#2893)
Browse files Browse the repository at this point in the history
Switch to using `go mod tidy` instead of `go mod download` to work
around golang/go#44129. This caused tests to
fail due to using `go1.16.x`, which is susceptible to this bug (`go1.17`
will have the fix).



---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
  • Loading branch information
RomainMuller authored Jun 29, 2021
1 parent d9028c8 commit 6e6ad69
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/jsii-pacmak/lib/targets/go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ export class Golang extends Target {

try {
// 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.path], {
// modules explicit so go.sum is updated. We'd normally want to use
// `go mod download`, but because of a bug in go 1.16, we have to use
// `go mod tidy` instead.
//
// See: https://github.com/golang/go/issues/44129
await go('mod', ['tidy', '-modfile', localGoMod.path], {
cwd: pkgDir,
});
} catch (e) {
Expand Down Expand Up @@ -125,6 +129,7 @@ export class Golang extends Target {
await fs.writeFile(path.join(pkgDir, localGoMod), content, {
encoding: 'utf-8',
});

return { path: localGoMod, content };
}
}
Expand Down

0 comments on commit 6e6ad69

Please sign in to comment.