Skip to content

Commit

Permalink
Add linting rules for replace directives in go.mod (#2638) (#2698)
Browse files Browse the repository at this point in the history
* Add linting rules for `replace` directives in go.mod

* Adding test replace dependencies

* Commenting out local replace

* Run go mod tidy

* Enable the linter

* Add back both test examples

* Removing local example

* Trying out nolint

* Trying again

* Trying another way

* Removing test replace directive

(cherry picked from commit 3aeb206)

Co-authored-by: Shaunak Kashyap <[email protected]>
  • Loading branch information
mergify[bot] and ycombinator authored May 16, 2023
1 parent 030a5f8 commit 80e3a2c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ linters:
- unconvert # Remove unnecessary type conversions
- wastedassign # wastedassign finds wasted assignment statements.
- gomodguard # check for blocked dependencies
- gomoddirectives

# all available settings of specific linters
linters-settings:
Expand Down Expand Up @@ -99,6 +100,20 @@ linters-settings:
- fmt
reason: "This package is deprecated, use `fmt.Errorf` with `%w` instead"

gomoddirectives:
# Forbid local `replace` directives
replace-local: false

# Forbid any `replace` directives that are intended temporarily only during
# development. The modules listed below are intended to be replaced permanently.
replace-allow-list:
- github.com/Microsoft/go-winio
- github.com/Shopify/sarama
- github.com/dop251/goja
- github.com/dop251/goja_nodejs
- github.com/fsnotify/fsnotify
- github.com/tonistiigi/fifo

gosimple:
# Select the Go version to target. The default is '1.13'.
go: "1.19.9"
Expand Down

0 comments on commit 80e3a2c

Please sign in to comment.