Skip to content

Commit 4f73489

Browse files
authored
Merge pull request #163 from cisagov/improvement/add_goimports_hook
Add a pre-commit hook to run `goimports`
2 parents 81735c2 + c7b18dc commit 4f73489

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ jobs:
121121
PACKAGE_URL: github.com/go-critic/go-critic/cmd/gocritic
122122
PACKAGE_VERSION: ${{ steps.setup-env.outputs.go-critic-version }}
123123
run: go install ${PACKAGE_URL}@${PACKAGE_VERSION}
124+
- name: Install goimports
125+
env:
126+
PACKAGE_URL: golang.org/x/tools/cmd/goimports
127+
PACKAGE_VERSION: ${{ steps.setup-env.outputs.goimports-version }}
128+
run: go install ${PACKAGE_URL}@${PACKAGE_VERSION}
124129
- name: Install gosec
125130
env:
126131
PACKAGE_URL: github.com/securego/gosec/v2/cmd/gosec

.pre-commit-config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ repos:
8585
- id: go-vet-repo-mod
8686
# GoSec
8787
- id: go-sec-repo-mod
88-
88+
# goimports
89+
- id: go-imports-repo
90+
args:
91+
# Write changes to files
92+
- -w
8993
# Nix hooks
9094
- repo: https://github.com/nix-community/nixpkgs-fmt
9195
rev: v1.3.0

0 commit comments

Comments
 (0)