build: more flags
All checks were successful
submodules sync / sync (push) Successful in 36s
build / build (push) Successful in 1m53s
build / trigger-build-image (push) Successful in 8s

This commit is contained in:
张泊明518370910136 2025-03-06 16:18:18 -05:00
parent 149ea41b1c
commit 792af0bd3c
GPG Key ID: D47306D7062CDA9D

View File

@ -6,17 +6,20 @@ APPS := $(notdir $(wildcard ./cmd/*))
COMMIT_HASH := $(shell git rev-parse --short HEAD) COMMIT_HASH := $(shell git rev-parse --short HEAD)
DATE := $(shell date +"%Y%m%d-%H%M%S") DATE := $(shell date +"%Y%m%d-%H%M%S")
VERSION := $(COMMIT_HASH)-$(DATE) VERSION := $(COMMIT_HASH)-$(DATE)
FLAGS := "-s -w -X main.Version=$(VERSION)" LDFLAGS := -s -w -X main.Version=$(VERSION)
GOFLAGS := -trimpath -mod=readonly -buildvcs=false
all: build all: build
build: build:
$(foreach APP,$(APPS), CGO_ENABLED=0 go build -ldflags=$(FLAGS) -o $(BUILD_DIR)/$(APP) ./cmd/$(APP);) $(foreach APP,$(APPS), \
CGO_ENABLED=0 \
go build $(GOFLAGS) -ldflags='$(LDFLAGS)' -o $(BUILD_DIR)/$(APP) ./cmd/$(APP) \
|| exit 1; \
)
clean: clean:
rm -rf $(BUILD_DIR)/* $(RM) -rv $(BUILD_DIR) $(TMP_DIR) *.out
rm -rf $(TMP_DIR)/*
rm -rf *.out
lint: lint:
golangci-lint run -v golangci-lint run -v