Skip to content

Commit

Permalink
chore(#57): add new stage for go fmt check (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
sathia27 authored and MalloZup committed Oct 17, 2019
1 parent 46aee69 commit 6282dc0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ git:
depth: 1
go_import_path: github.com/Clusterlab/ha_cluster_exporter

script:
- make
jobs:
include:
- stage: Go fmt
- script: ./go_lint.sh
- stage: Build
- script: make
11 changes: 11 additions & 0 deletions go_lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# NOTE: This script needs be run from the root of the GD2 repository

# Find all Go source files in the repository, that are not vendored or generated
# and then run gofmt on them
GOFMT_FILE_LIST=$(gofmt -l . | grep -v vendor)
if [ -n "${GOFMT_FILE_LIST}" ]; then
printf >&2 'gofmt failed for the following files:\n%s\n\nplease run "gofmt -w ." on your changes before committing.\n' "${GOFMT_FILE_LIST}"
exit 1
fi

0 comments on commit 6282dc0

Please sign in to comment.