From d9b5c2e560e2440727d6350096f468c9f1ca8870 Mon Sep 17 00:00:00 2001 From: Soam Vasani Date: Thu, 8 Feb 2018 18:55:49 -0800 Subject: [PATCH] Go builder for single file functions (#492) Add support to go builder for building a single file (otherwise even a single file needs to be archived in a .zip) --- environments/go/builder/build.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/environments/go/builder/build.sh b/environments/go/builder/build.sh index 62bed36d..3ece7d94 100755 --- a/environments/go/builder/build.sh +++ b/environments/go/builder/build.sh @@ -1,4 +1,19 @@ #!/bin/sh -cd ${SRC_PKG} -go build -buildmode=plugin -i -o ${DEPLOY_PKG} . +if [ -d ${SRC_PKG} ] +then + echo "Building in directory ${SRC_PKG}" + cd ${SRC_PKG} + go build -buildmode=plugin -i -o ${DEPLOY_PKG} . +elif [ -f ${SRC_PKG} ] +then + fn=$(basename ${SRC_PKG}) + d=/tmp/$fn + mkdir $d + trap "rm -rf /tmp/$fn" EXIT + echo "Building file ${SRC_PKG} in $d" + + cd $d + cp ${SRC_PKG} ./function.go + go build -buildmode=plugin -i -o ${DEPLOY_PKG} . +fi