Skip to content

Commit a8a639e

Browse files
authored
fix(lambda-go): path with space breaks go build (#28554)
Output path with space breaks go build Solution: quoting `go build` output path Closes #28555 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 669e6ff commit a8a639e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

packages/@aws-cdk/aws-lambda-go-alpha/lib/bundling.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export class Bundling implements cdk.BundlingOptions {
209209
const goBuildCommand: string = [
210210
'go', 'build',
211211
hasVendor ? '-mod=vendor': '',
212-
'-o', `${pathJoin(outputDir, 'bootstrap')}`,
212+
'-o', `"${pathJoin(outputDir, 'bootstrap')}"`,
213213
`${this.props.goBuildFlags ? this.props.goBuildFlags.join(' ') : ''}`,
214214
`${this.relativeEntryPath.replace(/\\/g, '/')}`,
215215
].filter(c => !!c).join(' ');

packages/@aws-cdk/aws-lambda-go-alpha/test/bundling.test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ test('bundling', () => {
5353
command: [
5454
'bash', '-c',
5555
[
56-
'go build -o /asset-output/bootstrap ./cmd/api',
56+
'go build -o "/asset-output/bootstrap" ./cmd/api',
5757
].join(' && '),
5858
],
5959
}),
@@ -81,7 +81,7 @@ test('bundling with file as entry', () => {
8181
command: [
8282
'bash', '-c',
8383
[
84-
'go build -o /asset-output/bootstrap ./main.go',
84+
'go build -o "/asset-output/bootstrap" ./main.go',
8585
].join(' && '),
8686
],
8787
}),
@@ -102,7 +102,7 @@ test('bundling with file in subdirectory as entry', () => {
102102
command: [
103103
'bash', '-c',
104104
[
105-
'go build -o /asset-output/bootstrap ./cmd/api/main.go',
105+
'go build -o "/asset-output/bootstrap" ./cmd/api/main.go',
106106
].join(' && '),
107107
],
108108
}),
@@ -123,7 +123,7 @@ test('bundling with file other than main.go in subdirectory as entry', () => {
123123
command: [
124124
'bash', '-c',
125125
[
126-
'go build -o /asset-output/bootstrap ./cmd/api/api.go',
126+
'go build -o "/asset-output/bootstrap" ./cmd/api/api.go',
127127
].join(' && '),
128128
],
129129
}),
@@ -265,7 +265,7 @@ test('Go build flags can be passed', () => {
265265
command: [
266266
'bash', '-c',
267267
[
268-
'go build -o /asset-output/bootstrap -ldflags "-s -w" ./cmd/api',
268+
'go build -o "/asset-output/bootstrap" -ldflags "-s -w" ./cmd/api',
269269
].join(' && '),
270270
],
271271
}),
@@ -297,7 +297,7 @@ test('AssetHashType can be specified', () => {
297297
command: [
298298
'bash', '-c',
299299
[
300-
'go build -o /asset-output/bootstrap ./cmd/api',
300+
'go build -o "/asset-output/bootstrap" ./cmd/api',
301301
].join(' && '),
302302
],
303303
}),

0 commit comments

Comments
 (0)