aboutsummaryrefslogtreecommitdiffstats
path: root/src/dma/vendor/github.com/streadway/amqp/pre-commit
diff options
context:
space:
mode:
Diffstat (limited to 'src/dma/vendor/github.com/streadway/amqp/pre-commit')
-rwxr-xr-xsrc/dma/vendor/github.com/streadway/amqp/pre-commit67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/dma/vendor/github.com/streadway/amqp/pre-commit b/src/dma/vendor/github.com/streadway/amqp/pre-commit
new file mode 100755
index 00000000..37155300
--- /dev/null
+++ b/src/dma/vendor/github.com/streadway/amqp/pre-commit
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+LATEST_STABLE_SUPPORTED_GO_VERSION="1.11"
+
+main() {
+ if local_go_version_is_latest_stable
+ then
+ run_gofmt
+ run_golint
+ run_govet
+ fi
+ run_unit_tests
+}
+
+local_go_version_is_latest_stable() {
+ go version | grep -q $LATEST_STABLE_SUPPORTED_GO_VERSION
+}
+
+log_error() {
+ echo "$*" 1>&2
+}
+
+run_gofmt() {
+ GOFMT_FILES=$(gofmt -l .)
+ if [ -n "$GOFMT_FILES" ]
+ then
+ log_error "gofmt failed for the following files:
+$GOFMT_FILES
+
+please run 'gofmt -w .' on your changes before committing."
+ exit 1
+ fi
+}
+
+run_golint() {
+ GOLINT_ERRORS=$(golint ./... | grep -v "Id should be")
+ if [ -n "$GOLINT_ERRORS" ]
+ then
+ log_error "golint failed for the following reasons:
+$GOLINT_ERRORS
+
+please run 'golint ./...' on your changes before committing."
+ exit 1
+ fi
+}
+
+run_govet() {
+ GOVET_ERRORS=$(go tool vet ./*.go 2>&1)
+ if [ -n "$GOVET_ERRORS" ]
+ then
+ log_error "go vet failed for the following reasons:
+$GOVET_ERRORS
+
+please run 'go tool vet ./*.go' on your changes before committing."
+ exit 1
+ fi
+}
+
+run_unit_tests() {
+ if [ -z "$NOTEST" ]
+ then
+ log_error 'Running short tests...'
+ env AMQP_URL= go test -short
+ fi
+}
+
+main