File: fmtpolice

package info (click to toggle)
golang-github-manyminds-api2go 1.0-RC2%2Bgit20161229.31.dc368bb-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 484 kB
  • ctags: 488
  • sloc: sh: 23; makefile: 3
file content (30 lines) | stat: -rwxr-xr-x 499 bytes parent folder | download | duplicates (3)
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
28
29
30
#!/bin/bash

readonly GOPATH="${GOPATH%%:*}"

main() {
  check_fmt
  check_lint
}

check_fmt() {
  eval "set -e"
  for file in $(git ls-files '*.go') ; do
    gofmt -s $file | diff -u $file -
  done
  eval "set +e"
}

check_lint() {
  for file in $(git ls-files '*.go') ; do
    if [[ ! "$(${GOPATH}/bin/golint $file)" =~ ^[[:blank:]]*$ ]] ; then
      _lint_verbose && exit 1
    fi
  done
}

_lint_verbose() {
  for file in $(git ls-files '*.go') ; do $GOPATH/bin/golint $file ; done
}

main "$@"