mercedes-benz / sechub

SecHub provides a central API to test software with different security tools.
https://mercedes-benz.github.io/sechub/
MIT License
263 stars 63 forks source link

Strip the SecHub Go client binaries #173

Closed sven-dmlr closed 4 years ago

sven-dmlr commented 4 years ago

The resulted binaries can be made at least 30% smaller by stripping off the debugging informations. This is done by use of the -s and -w linker flags when compiling.

sven-dmlr commented 4 years ago

Solution: add -ldflags="-s -w" to go build command.

Comparison: Before:

-rwxrwxr-x 1 developer developer 8536688 Feb  5 13:14 sechub-cli/build/go/platform/darwin-amd64/sechub
-rwxrwxr-x 1 developer developer 7316532 Feb  5 13:14 sechub-cli/build/go/platform/linux-386/sechub
-rwxrwxr-x 1 developer developer 8512114 Feb  5 13:14 sechub-cli/build/go/platform/linux-amd64/sechub
-rwxrwxr-x 1 developer developer 8245907 Feb  5 13:14 sechub-cli/build/go/platform/linux-arm64/sechub
-rwxrwxr-x 1 developer developer 7448130 Feb  5 13:14 sechub-cli/build/go/platform/linux-arm/sechub
-rwxrwxr-x 1 developer developer 7270912 Feb  5 13:14 sechub-cli/build/go/platform/windows-386/sechub.exe
-rwxrwxr-x 1 developer developer 8367104 Feb  5 13:14 sechub-cli/build/go/platform/windows-amd64/sechub.exe

After:

-rwxrwxr-x 1 developer developer 6025840 Feb  5 14:13 sechub-cli/build/go/platform/darwin-amd64/sechub
-rwxrwxr-x 1 developer developer 4637312 Feb  5 14:13 sechub-cli/build/go/platform/linux-386/sechub
-rwxrwxr-x 1 developer developer 5509056 Feb  5 14:13 sechub-cli/build/go/platform/linux-amd64/sechub
-rwxrwxr-x 1 developer developer 5088608 Feb  5 14:13 sechub-cli/build/go/platform/linux-arm64/sechub
-rwxrwxr-x 1 developer developer 4661160 Feb  5 14:13 sechub-cli/build/go/platform/linux-arm/sechub
-rwxrwxr-x 1 developer developer 4602880 Feb  5 14:13 sechub-cli/build/go/platform/windows-386/sechub.exe
-rwxrwxr-x 1 developer developer 5465088 Feb  5 14:13 sechub-cli/build/go/platform/windows-amd64/sechub.exe