You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: Use go 1.24's 'go tool' support for CLI tooling
This change mirrors a change already made to avalanchego and avoids
the problem of a cached version of golangci-lint being incompatible
with a new version of golang when upgrading the golang version between
minor versions.
Copy file name to clipboardExpand all lines: .github/CONTRIBUTING.md
+27-4Lines changed: 27 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,13 +40,13 @@ Mocks are auto-generated using [mockgen](https://pkg.go.dev/go.uber.org/mock/moc
40
40
* To **re-generate all mocks**, use the command below from the root of the project:
41
41
42
42
```sh
43
-
go generate -run "go.uber.org/mock/mockgen" ./...
43
+
go generate -run mockgen ./...
44
44
```
45
45
46
46
* To **add** an interface that needs a corresponding mock generated:
47
47
*if the file `mocks_generate_test.go` exists in the package where the interface is located, either:
48
-
* modify its `//go:generate go run go.uber.org/mock/mockgen` to generate a mock for your interface (preferred); or
49
-
* add another `//go:generate go run go.uber.org/mock/mockgen` to generate a mock for your interface according to specific mock generation settings
48
+
* modify its `//go:generate go tool -modfile=tools/go.mod mockgen` to generate a mock for your interface (preferred); or
49
+
* add another `//go:generate go tool -modfile=tools/go.mod mockgen` to generate a mock for your interface according to specific mock generation settings
50
50
*if the file `mocks_generate_test.go` does not exist in the package where the interface is located, create it with content (adapt as needed):
51
51
52
52
```go
@@ -55,7 +55,7 @@ Mocks are auto-generated using [mockgen](https://pkg.go.dev/go.uber.org/mock/moc
55
55
56
56
package mypackage
57
57
58
-
//go:generate go run go.uber.org/mock/mockgen -package=${GOPACKAGE} -destination=mocks_test.go . YourInterface
58
+
//go:generate go tool -modfile=tools/go.mod mockgen -package=${GOPACKAGE} -destination=mocks_test.go . YourInterface
59
59
```
60
60
61
61
Notes:
@@ -66,3 +66,26 @@ Mocks are auto-generated using [mockgen](https://pkg.go.dev/go.uber.org/mock/moc
66
66
1. If the `//go:generate` mockgen command line:
67
67
* generates a mock file for multiple interfaces, remove your interface from the line
68
68
* generates a mock file only for the interface, remove the entire line. If the file is empty, remove `mocks_generate_test.go` as well.
69
+
70
+
## Tool Dependencies
71
+
72
+
This project uses `go tool` to manage development tool dependencies in`tools/go.mod`. This isolates tool dependencies from the main application dependencies and provides consistent, version-locked tools across the team.
73
+
74
+
### Managing Tools
75
+
76
+
* To **add a new tool**:
77
+
```sh
78
+
go get -tool -modfile=tools/go.mod example.com/tool/cmd/toolname@version
79
+
```
80
+
81
+
* To **upgrade a tool**:
82
+
```sh
83
+
go get -tool -modfile=tools/go.mod example.com/tool/cmd/toolname@newversion
84
+
```
85
+
86
+
* To **run a tool manually**:
87
+
```sh
88
+
go tool -modfile=tools/go.mod toolname [args...]
89
+
```
90
+
91
+
Note: `ginkgo` remains in the main `go.mod` as it is used directly in e2e test code.
0 commit comments