This repository has been archived on 2022-08-17. You can view files and clone it, but cannot push or open issues or pull requests.
dex/scripts/check-go-version
charles.deng d92c21b9f9
Update check go major version way
the previous one just keep one prefix number as the major number, it should be the whole number after the dot.
2018-03-07 23:34:08 +08:00

33 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
set -e
VERSION=$( go version )
# For development versions of Go, these will be empty.
MAJOR_GOVERSION=$( echo -n "$VERSION" | grep -o 'go1\.[0-9]*' || true )
FULL_GOVERSION=$( echo -n "$VERSION" | grep -o 'go1\.[0-9|\.]*' || true )
# The list of unsupported major go versions.
UNSUPPORTED=( "go1.0" "go1.1" "go1.2" "go1.3" "go1.4" "go1.5" "go1.6" "go1.7" )
# Minor go versions which have known security vulnerabilities. Refuse to build with these.
#
# There aren't any security issues that impact dex in current Go versions but minor versions
# should be added here later if they do have issues.
KNOWN_INSECURE=( )
for V in "${UNSUPPORTED[@]}"; do
if [ "$V" = "$MAJOR_GOVERSION" ]; then
>&2 echo "ERROR: dex requires Go version 1.8+. Please update your Go installation: https://golang.org/dl/"
exit 2
fi
done
for V in "${KNOWN_INSECURE[@]}"; do
if [ "$V" = "$FULL_GOVERSION" ]; then
>&2 echo "Go version ${V} has known security vulnerabilities which impact dex. Please update your Go version."
exit 2
fi
done