Enable go module support for go environment (#1152)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
set -eux
|
||||
|
||||
@@ -6,6 +6,9 @@ srcDir=${GOPATH}/src/$(basename ${SRC_PKG})
|
||||
|
||||
trap "rm -rf ${srcDir}" EXIT
|
||||
|
||||
# http://ask.xmodulo.com/compare-two-version-numbers.html
|
||||
version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
|
||||
|
||||
if [ -d ${SRC_PKG} ]
|
||||
then
|
||||
echo "Building in directory ${srcDir}"
|
||||
@@ -18,4 +21,17 @@ then
|
||||
fi
|
||||
|
||||
cd ${srcDir}
|
||||
|
||||
if [ -f "go.mod" ]; then
|
||||
if [ ! -z ${GOLANG_VERSION} ] && version_ge ${GOLANG_VERSION} "1.12"; then
|
||||
go mod download
|
||||
else
|
||||
echo "Please update fission/go-builder and fission/go-env image to the latest version to support go module"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# still need to do this; otherwise, go will complain "cannot find main module".
|
||||
go mod init
|
||||
fi
|
||||
|
||||
go build -buildmode=plugin -i -o ${DEPLOY_PKG} .
|
||||
|
||||
Reference in New Issue
Block a user