diff --git a/environments/go/builder/build.sh b/environments/go/builder/build.sh index e2fa20a9..435dfd47 100755 --- a/environments/go/builder/build.sh +++ b/environments/go/builder/build.sh @@ -22,16 +22,18 @@ fi cd ${srcDir} -if [ -f "go.mod" ]; then - if [ ! -z ${GOLANG_VERSION} ] && version_ge ${GOLANG_VERSION} "1.12"; then +if [ ! -z ${GOLANG_VERSION} ] && version_ge ${GOLANG_VERSION} "1.12"; then + if [ -f "go.mod" ]; then go mod download else + # still need to do this; otherwise, go will complain "cannot find main module". + go mod init + fi +else # go version lower than go 1.12 + if [ -f "go.mod" ]; then 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} .