serverless-plugin-go 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.cz.toml CHANGED
@@ -1,7 +1,7 @@
1
1
  [tool]
2
2
  [tool.commitizen]
3
3
  name = "cz_customize"
4
- version = "0.1.3"
4
+ version = "0.1.4"
5
5
  tag_format = "v$version"
6
6
  bump_message = "bump: release $current_version → $new_version [skip-ci]"
7
7
  update_changelog_on_bump = true
package/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.1.4 (2026-11-13)
2
+
3
+
4
+ - fix: default GOFLAGS=-trimpath -buildvcs=false and merge custom env with defaults (#14)
5
+
1
6
  ## v0.1.3 (2026-11-10)
2
7
 
3
8
 
package/README.md CHANGED
@@ -62,6 +62,9 @@ custom:
62
62
  env:
63
63
  GOOS: 'linux' # Default compile OS
64
64
  CGO_ENABLED: '0' # By default CGO is disabled
65
+ GOFLAGS: '-trimpath -buildvcs=false' # Reproducible builds by default
66
+ # Variables you define are merged with these defaults; redefining one (e.g. GOFLAGS) replaces
67
+ # its whole value. These values also override any same-named variable from the shell.
65
68
 
66
69
  # Bash commands to execute before compilation
67
70
  # These commands will be executed once before all compilations
package/index.js CHANGED
@@ -30,6 +30,7 @@ export default class Go {
30
30
  env: {
31
31
  CGO_ENABLED: "0",
32
32
  GOOS: "linux",
33
+ GOFLAGS: "-trimpath -buildvcs=false", // reproducible builds
33
34
  },
34
35
  cmd: 'go build -ldflags="-s -w"',
35
36
  monorepo: false,
@@ -291,7 +292,11 @@ export default class Go {
291
292
  const service = this.serverless.service;
292
293
 
293
294
  if (service.custom && service.custom.go) {
294
- config = { ...config, ...service.custom.go };
295
+ config = {
296
+ ...config,
297
+ ...service.custom.go,
298
+ env: { ...config.env, ...service.custom.go.env },
299
+ };
295
300
  }
296
301
 
297
302
  for (let env of Object.keys(config.env)) {
package/index.test.js CHANGED
@@ -94,7 +94,12 @@ describe("Go Plugin", () => {
94
94
  cwd: ".",
95
95
  env: {
96
96
  ...process.env,
97
- ...{ CGO_ENABLED: "0", GOOS: "linux", GOARCH: "amd64" },
97
+ ...{
98
+ CGO_ENABLED: "0",
99
+ GOOS: "linux",
100
+ GOFLAGS: "-trimpath -buildvcs=false",
101
+ GOARCH: "amd64",
102
+ },
98
103
  },
99
104
  },
100
105
  );
@@ -109,7 +114,12 @@ describe("Go Plugin", () => {
109
114
  cwd: ".",
110
115
  env: {
111
116
  ...process.env,
112
- ...{ CGO_ENABLED: "0", GOOS: "linux", GOARCH: "amd64" },
117
+ ...{
118
+ CGO_ENABLED: "0",
119
+ GOOS: "linux",
120
+ GOFLAGS: "-trimpath -buildvcs=false",
121
+ GOARCH: "amd64",
122
+ },
113
123
  },
114
124
  },
115
125
  );
@@ -124,7 +134,12 @@ describe("Go Plugin", () => {
124
134
  cwd: ".",
125
135
  env: {
126
136
  ...process.env,
127
- ...{ CGO_ENABLED: "0", GOOS: "linux", GOARCH: "amd64" },
137
+ ...{
138
+ CGO_ENABLED: "0",
139
+ GOOS: "linux",
140
+ GOFLAGS: "-trimpath -buildvcs=false",
141
+ GOARCH: "amd64",
142
+ },
128
143
  },
129
144
  },
130
145
  );
@@ -139,7 +154,12 @@ describe("Go Plugin", () => {
139
154
  cwd: ".",
140
155
  env: {
141
156
  ...process.env,
142
- ...{ CGO_ENABLED: "0", GOOS: "linux", GOARCH: "amd64" },
157
+ ...{
158
+ CGO_ENABLED: "0",
159
+ GOOS: "linux",
160
+ GOFLAGS: "-trimpath -buildvcs=false",
161
+ GOARCH: "amd64",
162
+ },
143
163
  },
144
164
  },
145
165
  );
@@ -175,7 +195,12 @@ describe("Go Plugin", () => {
175
195
  cwd: ".",
176
196
  env: {
177
197
  ...process.env,
178
- ...{ CGO_ENABLED: "0", GOOS: "linux", GOARCH: "amd64" },
198
+ ...{
199
+ CGO_ENABLED: "0",
200
+ GOOS: "linux",
201
+ GOFLAGS: "-trimpath -buildvcs=false",
202
+ GOARCH: "amd64",
203
+ },
179
204
  },
180
205
  },
181
206
  );
@@ -209,7 +234,12 @@ describe("Go Plugin", () => {
209
234
  cwd: ".",
210
235
  env: {
211
236
  ...process.env,
212
- ...{ CGO_ENABLED: "0", GOOS: "linux", GOARCH: "arm64" },
237
+ ...{
238
+ CGO_ENABLED: "0",
239
+ GOOS: "linux",
240
+ GOFLAGS: "-trimpath -buildvcs=false",
241
+ GOARCH: "arm64",
242
+ },
213
243
  },
214
244
  },
215
245
  );
@@ -245,7 +275,12 @@ describe("Go Plugin", () => {
245
275
  cwd: "gopath",
246
276
  env: {
247
277
  ...process.env,
248
- ...{ CGO_ENABLED: "0", GOOS: "linux", GOARCH: "amd64" },
278
+ ...{
279
+ CGO_ENABLED: "0",
280
+ GOOS: "linux",
281
+ GOFLAGS: "-trimpath -buildvcs=false",
282
+ GOARCH: "amd64",
283
+ },
249
284
  },
250
285
  },
251
286
  );
@@ -349,7 +384,12 @@ describe("Go Plugin", () => {
349
384
  cwd: ".",
350
385
  env: {
351
386
  ...process.env,
352
- ...{ CGO_ENABLED: "0", GOOS: "linux", GOARCH: "amd64" },
387
+ ...{
388
+ CGO_ENABLED: "0",
389
+ GOOS: "linux",
390
+ GOFLAGS: "-trimpath -buildvcs=false",
391
+ GOARCH: "amd64",
392
+ },
353
393
  },
354
394
  },
355
395
  );
@@ -394,7 +434,12 @@ describe("Go Plugin", () => {
394
434
  cwd: "functions/func1",
395
435
  env: {
396
436
  ...process.env,
397
- ...{ CGO_ENABLED: "0", GOOS: "linux", GOARCH: "amd64" },
437
+ ...{
438
+ CGO_ENABLED: "0",
439
+ GOOS: "linux",
440
+ GOFLAGS: "-trimpath -buildvcs=false",
441
+ GOARCH: "amd64",
442
+ },
398
443
  },
399
444
  },
400
445
  );
@@ -409,7 +454,12 @@ describe("Go Plugin", () => {
409
454
  cwd: "functions/func2",
410
455
  env: {
411
456
  ...process.env,
412
- ...{ CGO_ENABLED: "0", GOOS: "linux", GOARCH: "amd64" },
457
+ ...{
458
+ CGO_ENABLED: "0",
459
+ GOOS: "linux",
460
+ GOFLAGS: "-trimpath -buildvcs=false",
461
+ GOARCH: "amd64",
462
+ },
413
463
  },
414
464
  },
415
465
  );
@@ -438,6 +488,19 @@ describe("Go Plugin", () => {
438
488
  );
439
489
  });
440
490
 
491
+ it("Merges custom env with default env", async () => {
492
+ config.service.setCustom({ go: { env: { FOO: "x" } } });
493
+
494
+ const plugin = new Go(config);
495
+
496
+ expect(plugin.config.env).to.deep.equal({
497
+ CGO_ENABLED: "0",
498
+ GOOS: "linux",
499
+ GOFLAGS: "-trimpath -buildvcs=false",
500
+ FOO: "x",
501
+ });
502
+ });
503
+
441
504
  it("Should get concurrency config", async () => {
442
505
  config.service.setFunctions({
443
506
  testFunc1: {
@@ -524,11 +587,25 @@ describe("Go Plugin", () => {
524
587
  // Verify beforeBuild commands were executed once
525
588
  expect(execStub).to.have.been.calledWith("echo 'before build command'", {
526
589
  cwd: ".",
527
- env: { ...process.env, ...{ CGO_ENABLED: "0", GOOS: "linux" } },
590
+ env: {
591
+ ...process.env,
592
+ ...{
593
+ CGO_ENABLED: "0",
594
+ GOOS: "linux",
595
+ GOFLAGS: "-trimpath -buildvcs=false",
596
+ },
597
+ },
528
598
  });
529
599
  expect(execStub).to.have.been.calledWith("go mod tidy", {
530
600
  cwd: ".",
531
- env: { ...process.env, ...{ CGO_ENABLED: "0", GOOS: "linux" } },
601
+ env: {
602
+ ...process.env,
603
+ ...{
604
+ CGO_ENABLED: "0",
605
+ GOOS: "linux",
606
+ GOFLAGS: "-trimpath -buildvcs=false",
607
+ },
608
+ },
532
609
  });
533
610
 
534
611
  // Verify compilation commands were executed for each function
@@ -538,7 +615,12 @@ describe("Go Plugin", () => {
538
615
  cwd: ".",
539
616
  env: {
540
617
  ...process.env,
541
- ...{ CGO_ENABLED: "0", GOOS: "linux", GOARCH: "amd64" },
618
+ ...{
619
+ CGO_ENABLED: "0",
620
+ GOOS: "linux",
621
+ GOFLAGS: "-trimpath -buildvcs=false",
622
+ GOARCH: "amd64",
623
+ },
542
624
  },
543
625
  },
544
626
  );
@@ -548,7 +630,12 @@ describe("Go Plugin", () => {
548
630
  cwd: ".",
549
631
  env: {
550
632
  ...process.env,
551
- ...{ CGO_ENABLED: "0", GOOS: "linux", GOARCH: "amd64" },
633
+ ...{
634
+ CGO_ENABLED: "0",
635
+ GOOS: "linux",
636
+ GOFLAGS: "-trimpath -buildvcs=false",
637
+ GOARCH: "amd64",
638
+ },
552
639
  },
553
640
  },
554
641
  );
@@ -584,11 +671,25 @@ describe("Go Plugin", () => {
584
671
  // Verify beforeBuild commands were executed once
585
672
  expect(execStub).to.have.been.calledWith("echo 'before build command'", {
586
673
  cwd: ".",
587
- env: { ...process.env, ...{ CGO_ENABLED: "0", GOOS: "linux" } },
674
+ env: {
675
+ ...process.env,
676
+ ...{
677
+ CGO_ENABLED: "0",
678
+ GOOS: "linux",
679
+ GOFLAGS: "-trimpath -buildvcs=false",
680
+ },
681
+ },
588
682
  });
589
683
  expect(execStub).to.have.been.calledWith("go mod tidy", {
590
684
  cwd: ".",
591
- env: { ...process.env, ...{ CGO_ENABLED: "0", GOOS: "linux" } },
685
+ env: {
686
+ ...process.env,
687
+ ...{
688
+ CGO_ENABLED: "0",
689
+ GOOS: "linux",
690
+ GOFLAGS: "-trimpath -buildvcs=false",
691
+ },
692
+ },
592
693
  });
593
694
 
594
695
  // Verify the compilation command was executed
@@ -598,7 +699,12 @@ describe("Go Plugin", () => {
598
699
  cwd: ".",
599
700
  env: {
600
701
  ...process.env,
601
- ...{ CGO_ENABLED: "0", GOOS: "linux", GOARCH: "amd64" },
702
+ ...{
703
+ CGO_ENABLED: "0",
704
+ GOOS: "linux",
705
+ GOFLAGS: "-trimpath -buildvcs=false",
706
+ GOARCH: "amd64",
707
+ },
602
708
  },
603
709
  },
604
710
  );
@@ -634,11 +740,25 @@ describe("Go Plugin", () => {
634
740
  // Verify beforeBuild commands were executed once
635
741
  expect(execStub).to.have.been.calledWith("echo 'before build command'", {
636
742
  cwd: ".",
637
- env: { ...process.env, ...{ CGO_ENABLED: "0", GOOS: "linux" } },
743
+ env: {
744
+ ...process.env,
745
+ ...{
746
+ CGO_ENABLED: "0",
747
+ GOOS: "linux",
748
+ GOFLAGS: "-trimpath -buildvcs=false",
749
+ },
750
+ },
638
751
  });
639
752
  expect(execStub).to.have.been.calledWith("go mod tidy", {
640
753
  cwd: ".",
641
- env: { ...process.env, ...{ CGO_ENABLED: "0", GOOS: "linux" } },
754
+ env: {
755
+ ...process.env,
756
+ ...{
757
+ CGO_ENABLED: "0",
758
+ GOOS: "linux",
759
+ GOFLAGS: "-trimpath -buildvcs=false",
760
+ },
761
+ },
642
762
  });
643
763
 
644
764
  // Verify compilation command was executed
@@ -648,7 +768,12 @@ describe("Go Plugin", () => {
648
768
  cwd: ".",
649
769
  env: {
650
770
  ...process.env,
651
- ...{ CGO_ENABLED: "0", GOOS: "linux", GOARCH: "amd64" },
771
+ ...{
772
+ CGO_ENABLED: "0",
773
+ GOOS: "linux",
774
+ GOFLAGS: "-trimpath -buildvcs=false",
775
+ GOARCH: "amd64",
776
+ },
652
777
  },
653
778
  },
654
779
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serverless-plugin-go",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "description": "Serverless Framework plugin that compiles Go functions on the fly",
6
6
  "main": "index.js",