-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlint.sh
More file actions
executable file
·27 lines (20 loc) · 926 Bytes
/
lint.sh
File metadata and controls
executable file
·27 lines (20 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
[ -z "$GO" ] && GO=go
[ -z "$GOLANGCI_LINT_VERSION" ] && GOLANGCI_LINT_VERSION="v2.3.1"
# detecting GOPATH and removing trailing "/" if any
GOPATH="$(go env GOPATH)"
GOPATH=${GOPATH%/}
# adding GOBIN to PATH
[[ ":$PATH:" != *"$GOPATH/bin"* ]] && PATH=$PATH:"$GOPATH"/bin
# checking if golangci-lint is available
if ! command -v golangci-lint-"$GOLANGCI_LINT_VERSION" >/dev/null; then
echo "Installing golangci-lint $GOLANGCI_LINT_VERSION..."
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /tmp "$GOLANGCI_LINT_VERSION" && mv /tmp/golangci-lint "$GOPATH"/bin/golangci-lint-"$GOLANGCI_LINT_VERSION"
fi
this_path=$(dirname "$0")
golangci_yml="./.golangci.yml"
if [ ! -f "./.golangci.yml" ]; then
golangci_yml="$this_path"/.golangci.yml
fi
echo "Checking packages."
golangci-lint-"$GOLANGCI_LINT_VERSION" run -c "$golangci_yml" ./... || exit 1