File: lib.sh

package info (click to toggle)
golang-github-henvic-httpretty 0.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 352 kB
  • sloc: sh: 61; makefile: 3
file content (13 lines) | stat: -rw-r--r-- 564 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
# ensure_go_binary verifies that a binary exists in $PATH corresponding to the
# given go-gettable URI. If no such binary exists, it is fetched via `go get`.
# Reference: https://github.com/golang/pkgsite/blob/65d33554b34b666d37b22bed7de136b562d5dba8/all.bash#L93-L103
# Copyright 2019 The Go Authors.
ensure_go_binary() {
  local binary=$(basename $1)
  if ! [ -x "$(command -v $binary)" ]; then
    echo "Installing: $1"
    # Run in a subshell for convenience, so that we don't have to worry about
    # our PWD.
    (set -x; cd && go install $1@latest)
  fi
}