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

27 lines
652 B

  1. #!/bin/bash
  2. set -euo pipefail
  3. f_sha256() {
  4. local l_file
  5. l_file=$1
  6. python -sBc "import hashlib;print(hashlib.sha256(open('$l_file','rb').read()).hexdigest())"
  7. }
  8. installer="$(mktemp)"
  9. trap "rm -f ${installer}" EXIT
  10. GOBIN="${1}"
  11. VERSION="${2}"
  12. HASHSUM="${3}"
  13. CURL="$(which curl)"
  14. echo "Downloading golangci-lint ${VERSION} installer ..." >&2
  15. "${CURL}" -sfL "https://raw.githubusercontent.com/golangci/golangci-lint/${VERSION}/install.sh" > "${installer}"
  16. echo "Checking hashsum ..." >&2
  17. [ "${HASHSUM}" = "$(f_sha256 ${installer})" ]
  18. chmod +x "${installer}"
  19. echo "Launching installer ..." >&2
  20. exec "${installer}" -d -b "${GOBIN}" "${VERSION}"