Skip to content

Commit 934226b

Browse files
authored
fix: Better Go build flags for plugins packaging (#2415)
#### Summary `trimpath` and `buildvcs` are better for cache re-usability and reproducible builds (we already include plugins versions in `resources/plugin.Version` so we don't need the VCS data). Also `mod=readonly` ensures `go build` doesn't modify `go.mod` or `go.sum` ---
1 parent 51f4d60 commit 934226b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

serve/package.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (s *PluginServe) build(pluginDirectory string, target plugin.BuildTarget, d
130130
stripSymbols = ""
131131
}
132132
ldFlags := fmt.Sprintf("%[1]s -w -X %[2]s/plugin.Version=%[3]s -X %[2]s/resources/plugin.Version=%[3]s", stripSymbols, importPath, pluginVersion)
133-
args := []string{"build", "-o", pluginPath, "-buildmode=exe", "-ldflags", ldFlags}
133+
args := []string{"build", "-trimpath", "-buildvcs=false", "-mod=readonly", "-o", pluginPath, "-buildmode=exe", "-ldflags", ldFlags}
134134
cmd := exec.Command("go", args...)
135135
cmd.Dir = pluginDirectory
136136
cmd.Stdout = os.Stdout

0 commit comments

Comments
 (0)