You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

verify-golang.sh 1.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/env bash
  2. # Copyright 2021 The KubeEdge Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. set -o errexit
  16. set -o nounset
  17. set -o pipefail
  18. # The root of the build/dist directory
  19. SEDNA_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
  20. source "${SEDNA_ROOT}/hack/lib/init.sh"
  21. if ! command -v go 2>/dev/null; then
  22. cat >&2 <<EOF
  23. Can't find 'go' in PATH, please fix and retry.
  24. See http://golang.org/doc/install for installation instructions.
  25. EOF
  26. exit 1
  27. fi
  28. echo "go detail version: $(go version)"
  29. # output of $(go version):
  30. # go version go1.15.6 linux/amd64
  31. goversion=$(go version|awk '$0=$3'|sed 's/go//g')
  32. X=$(echo $goversion|cut -d. -f1)
  33. Y=$(echo $goversion|cut -d. -f2)
  34. if [ $X -lt 1 ] ; then
  35. echo "go major version must >= 1, now is $X" >&2
  36. exit 1
  37. fi
  38. if [ $X -eq 1 -a $Y -lt 12 ] ; then
  39. echo "go minor version must >= 12 when major version is 1, now is $Y" >&2
  40. exit 1
  41. fi