From 4b7649c16e8bdfef01f842d01cb89da726bb448e Mon Sep 17 00:00:00 2001
From: Massimiliano Adamo <maxadamo@gmail.com>
Date: Wed, 25 Nov 2020 16:58:23 +0100
Subject: [PATCH] minor

---
 build.sh | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/build.sh b/build.sh
index db0ae87..3ce3ac7 100755
--- a/build.sh
+++ b/build.sh
@@ -1,9 +1,4 @@
 #!/bin/bash
-#if ! which upx &>/dev/null; then
-#    echo "please download upx here https://github.com/upx/upx/releases"
-#    echo "and store the executable within your \$PATH"
-#    exit
-#fi
 BIN_NAME=acme-downloader
 PATH=$PATH:$(go env GOPATH)/bin
 GOPATH=$(go env GOPATH)
@@ -14,6 +9,15 @@ export BIN_NAME PATH GOPATH
 PROG_VERSION="1.0"
 BUILDTIME=$(date -u '+%Y-%m-%d_%H:%M:%S')
 
+run_upx() {
+    if ! which upx &>/dev/null; then
+        echo "please download upx here https://github.com/upx/upx/releases"
+        echo "and store the executable within your \$PATH"
+        exit
+    fi
+    upx --brute ${GOPATH}/bin/${BIN_NAME}
+}
+
 rm -rf ${GOPATH}/src/github.com/maxadamo/${BIN_NAME} ${GOPATH}/src/gitlab.geant.net/devops/${BIN_NAME}
 go get -ldflags "-s -w -X main.appVersion=${PROG_VERSION} -X main.buildTime=${BUILDTIME}" gitlab.geant.net/devops/${BIN_NAME}
 #go get -ldflags "-s -w -X main.appVersion=${PROG_VERSION} -X main.buildTime=${BUILDTIME}" .
@@ -27,7 +31,7 @@ while true; do
     case $yn in
     [Yy]*)
         echo ""
-        upx --brute ${GOPATH}/bin/${BIN_NAME}
+        run_upx
         break
         ;;
     [Nn]*) break ;;
-- 
GitLab