Skip to content

Commit

Permalink
Add simple go hooks (#45)
Browse files Browse the repository at this point in the history
This allows us to reuse the go configuration accross different projects
  • Loading branch information
hofbi authored Nov 27, 2024
1 parent dfe2c1b commit bf9ae61
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@
entry: "sys.path.append"
language: pygrep
types: ["python"]
- id: go-fmt
name: Go Format
description: Format go files
entry: gofmt
args: [-s, -w, -d=false]
language: golang
types: [go]
- id: go-imports
name: Go Imports
description: Order go imports
entry: goimports
args: [-w, -d=false]
additional_dependencies: [golang.org/x/tools/cmd/goimports@v0.25.0]
language: golang
types: [go]
- id: go-revive
name: Go Revive
description: Run Go Revive linter
entry: revive
args: [-set_exit_status, -formatter, friendly]
additional_dependencies: [github.com/mgechev/revive@v1.3.9]
language: golang
types: [go]
- id: check-number-of-lines-count
name: Check Number of Lines
description: Check that number of lines in scripts do not exceed max-lines. Use `--max-lines=<number>` to set the maximum number of lines. Default is 30 for shell scripts.
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ These tools are used to help developers in their day-to-day tasks.
- [`check-cpp-and-cu-unit-test-naming-pattern`](#check-cpp-and-cu-unit-test-naming-pattern)
- [`check-no-dashes`](#check-no-dashes)
- [`check-sys-path-append`](#check-sys-path-append)
- [`go-fmt`](#go-fmt)
- [`go-imports`](#go-imports)
- [`go-revive`](#go-revive)
- [`check-number-of-lines-count`](#check-number-of-lines-count)
- [`check-shellscript-set-options`](#check-shellscript-set-options)
- [`check-jira-reference-in-todo`](#check-jira-reference-in-todo)
Expand Down Expand Up @@ -80,6 +83,18 @@ Check that markdown filenames do not use dashes

Check that no `sys.path.append` is used in Python code

### `go-fmt`

Format go files

### `go-imports`

Order go imports

### `go-revive`

Run Go Revive linter

### `check-number-of-lines-count`

Check that number of lines in scripts do not exceed max-lines. Use `--max-lines=<number>` to set the maximum number of lines. Default is 30 for shell scripts.
Expand Down

0 comments on commit bf9ae61

Please sign in to comment.