Skip to content

Commit

Permalink
chore: add -ldflags "-s -w"
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsuen committed Apr 2, 2024
1 parent 7a5cd4d commit 1ebda6f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,36 @@ clean:
@if [ -d ${DIR} ]; then rm -rf ${DIR}/*; else exit 0; fi

build:
go build -o ${DIR}/${APP} .
go build -o ${DIR}/${APP} -ldflags "-s -w" .

windows:
@# windows-amd64:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o ${DIR}/${APP}.exe .
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o ${DIR}/${APP}.exe -ldflags "-s -w" .
@cd ${DIR}/ && zip -qr ${APP}-windows_amd64.zip ${APP}.exe && rm -rf ${APP}.exe && cd ../
@# windows-arm64:
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -o ${DIR}/${APP}.exe .
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -o ${DIR}/${APP}.exe -ldflags "-s -w" .
@cd ${DIR}/ && zip -qr ${APP}-windows_arm64.zip ${APP}.exe && rm -rf ${APP}.exe && cd ../

linux:
@# linux-amd64:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ${DIR}/${APP} .
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ${DIR}/${APP} -ldflags "-s -w" .
@cd ${DIR}/ && tar -zcf ${APP}-linux_amd64.tar.gz ${APP} && rm -rf ${APP} && cd ../
@# linux-arm64:
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o ${DIR}/${APP} .
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o ${DIR}/${APP} -ldflags "-s -w" .
@cd ${DIR}/ && tar -zcf ${APP}-linux_arm64.tar.gz ${APP} && rm -rf ${APP} && cd ../

macos:
@# macos-amd64:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ${DIR}/${APP} .
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ${DIR}/${APP} -ldflags "-s -w" .
@cd ${DIR}/ && tar -zcf ${APP}-darwin_amd64.tar.gz ${APP} && rm -rf ${APP} && cd ../
@# macos-arm64:
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o ${DIR}/${APP} .
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o ${DIR}/${APP} -ldflags "-s -w" .
@cd ${DIR}/ && tar -zcf ${APP}-darwin_arm64.tar.gz ${APP} && rm -rf ${APP} && cd ../

freebsd:
@# freebsd-amd64:
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -o ${DIR}/${APP} .
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -o ${DIR}/${APP} -ldflags "-s -w" .
@cd ${DIR}/ && tar -jcf ${APP}-freebsd_amd64.tar.bz2 ${APP} && rm -rf ${APP} && cd ../
@# freebsd-arm64:
CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -o ${DIR}/${APP} .
CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -o ${DIR}/${APP} -ldflags "-s -w" .
@cd ${DIR}/ && tar -jcf ${APP}-freebsd_arm64.tar.bz2 ${APP} && rm -rf ${APP} && cd ../

0 comments on commit 1ebda6f

Please sign in to comment.