#!/usr/bin/env sh set -e SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) cd "$SCRIPT_DIR/.." # .custom-gcl.yaml is only discovered in the current directory BIN="bin/golint" STAMP="bin/.golint.stamp" # Everything that changes the compiled binary: the linter sources, and the build # config that pins the golangci-lint version the plugin links against. testdata # is excluded -- fixtures are not compiled into the binary. current_stamp() { { find pkg/ -type f ! -path '*/testdata/*' | sort | xargs sha256sum sha256sum .custom-gcl.yaml sha256sum root.go } | sha256sum | cut -d' ' -f1 } if [ "$1" = "--if-needed" ] && [ -x "$BIN" ] && [ -f "$STAMP" ] && [ "$(cat "$STAMP")" = "$(current_stamp)" ]; then exit 0 fi if ! [ -x "$(command -v golangci-lint)" ]; then echo "golangci-lint is not installed. Please install it from https://golangci-lint.run/welcome/install/" exit 1 fi echo "Building golint (golangci-lint + custom linters)..." golangci-lint custom current_stamp > "$STAMP" echo "Done: $SCRIPT_DIR/$BIN"