cisagov / skeleton-generic

A generic skeleton project for quickly getting a new cisagov project started.
Creative Commons Zero v1.0 Universal
14 stars 12 forks source link

Add a pre-commit hook to run `goimports` #163

Closed mcdonnnj closed 9 months ago

mcdonnnj commented 10 months ago

๐Ÿ—ฃ Description

This pull request adds a pre-commit hook to run goimports on any Go code in a repository.

๐Ÿ’ญ Motivation and context

Just as we use code formatters for other languages we use (black and isort for Python as an example) it would be good to do so for any Go code. The goimports tool takes the functionality of gofmt and adds import sorting/organization.

๐Ÿงช Testing

Automated tests pass. I verified that this will format code automatically against code locally and then this branch of cisagov/skeleton-golang-package had expected output since the code is already formatted by goimports.

โœ… Pre-approval checklist

โœ… Pre-merge checklist