Skip to content

Commit

Permalink
Merge pull request #2 from chrsblck/master
Browse files Browse the repository at this point in the history
Add goimports hook
  • Loading branch information
brikis98 authored May 16, 2018
2 parents 8ed7297 + b94f8d2 commit 26a4755
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
files: \.go$
exclude: vendor\/.*$

- id: goimports
name: goimports
description: Goimports updates imports and formats in the same style as gofmt
entry: hooks/goimports.sh
language: script
files: \.go$
exclude: vendor\/.*$

- id: golint
name: golint
description: Golint is a linter for Go source code.
Expand Down
12 changes: 12 additions & 0 deletions hooks/goimports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

# OSX GUI apps do not pick up environment variables the same way as Terminal apps and there are no easy solutions,
# especially as Apple changes the GUI app behavior every release (see https://stackoverflow.com/q/135688/483528). As a
# workaround to allow GitHub Desktop to work, add this (hopefully harmless) setting here.
export PATH=$PATH:/usr/local/bin

for file in "$@"; do
goimports -l -w "$(dirname "$file")"
done

0 comments on commit 26a4755

Please sign in to comment.