pre-commit

#!/bin/bash export GO_NAMES='\.(go)$' export GO_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E $GO_NAMES) function exit_err() { echo "❌ ????" ; exit 1; } if [[ ! -z $GO_FILES ]] then echo "Examining $GO_FILES" echo $GO_FILES | xargs gofmt -s -w || exit_err /usr/local/bin/golangci-lint run --color=always ./... || exit_err echo $GO_FILES | xargs git add else echo "nothing to do ????" exit 0 fi echo "✅ ????"
pre-commit for a go project

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.