.pre-build: mkdir -p bin/ # all=表示对所有go包应用后面的表示标志 # -N 禁用优化 # -l 禁用内联 # -ldflags 用来设置链接器的标志 # -X 在编译时设置包中的变量的值 build: .pre-build go build -gcflags='all=-N -l' -ldflags "-X agent/cmd/agent/config.Version=`./branch_info.sh get_version` -X agent/cmd/agent/config.BuildCommit=`git rev-list -1 HEAD`" -o bin/linkfog_agent ./cmd/agent bin/linkfog_agent -v | tee version build-dev: .pre-build go build -tags dev -gcflags='all=-N -l' -ldflags "-X agent/cmd/agent/config.Version=`./branch_info.sh get_version` -X agent/cmd/agent/config.BuildCommit=`git rev-list -1 HEAD`" -o bin/linkfog_agent ./cmd/agent bin/linkfog_agent -v | tee version