build: 禁用 CGO 以确保跨平台构建的一致性

- 在 Makefile 中添加 CGO_ENABLED=0 环境变量
- 此修改确保在不同平台上构建时不会链接 CGO 依赖
- 提高了构建过程的可移植性和一致性
This commit is contained in:
kingecg 2025-06-23 23:46:05 +08:00
parent 21289bb209
commit 8334efebd4
1 changed files with 2 additions and 1 deletions

View File

@ -1,10 +1,11 @@
Makefile
ARCHS := linux-amd64 linux-arm64 darwin-amd64
VERSION ?= $(shell git describe --tags --always)
all: $(ARCHS)
$(ARCHS):
@echo "Building for $(@)"
@GOOS=$(word 1,$(subst -, ,$(@))) GOARCH=$(word 2,$(subst -, ,$(@))) \
@GOOS=$(word 1,$(subst -, ,$(@))) GOARCH=$(word 2,$(subst -, ,$(@))) CGO_ENABLED=0 \
go build -ldflags "-X main.Version=$(VERSION)" -o target/$(@)/gohttpd
cp config.json target/$(@)/
cp -r adminui target/$(@)/