From 10a86e83c308edab39e365adde29f653a7e4b2e6 Mon Sep 17 00:00:00 2001 From: yue9944882 <291271447@qq.com> Date: Fri, 28 Feb 2020 13:17:05 +0800 Subject: [PATCH] overrideable CGO options --- cmd/apiserver-boot/boot/build/build_executables.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/apiserver-boot/boot/build/build_executables.go b/cmd/apiserver-boot/boot/build/build_executables.go index 2daab91997..c95183c5e1 100644 --- a/cmd/apiserver-boot/boot/build/build_executables.go +++ b/cmd/apiserver-boot/boot/build/build_executables.go @@ -188,7 +188,9 @@ func GoBuild(cmd *cobra.Command, args []string) { // Build the controller manager path := filepath.Join("cmd", "manager", "main.go") c := exec.Command("go", "build", "-o", filepath.Join(outputdir, "controller-manager"), path) - c.Env = append(os.Environ(), "CGO_ENABLED=0") + if len(os.Getenv("CGO_ENABLED")) == 0 { + c.Env = append(os.Environ(), "CGO_ENABLED=0") + } if len(goos) > 0 { c.Env = append(c.Env, fmt.Sprintf("GOOS=%s", goos)) }