From 01257e838b12250df5f470eef311fab5f80181bb Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sun, 24 Aug 2025 14:17:20 +0200 Subject: [PATCH] build: use Go 1.24 tools pattern (#10281) --- go.mod | 10 +- lib/config/mocks/mocked_wrapper.go | 54 ---------- lib/config/wrapper.go | 3 +- lib/connections/mocks/service.go | 12 --- lib/connections/service.go | 3 +- lib/discover/manager.go | 3 +- lib/discover/mocks/manager.go | 12 --- lib/events/events.go | 3 +- lib/events/mocks/buffered_subscription.go | 4 - lib/model/folder_summary.go | 3 +- lib/model/mocks/folderSummaryService.go | 4 - lib/model/mocks/model.go | 106 -------------------- lib/model/model.go | 3 +- lib/protocol/mocked_connection_info_test.go | 18 ---- lib/protocol/mocks/connection.go | 38 ------- lib/protocol/mocks/connection_info.go | 18 ---- lib/protocol/protocol.go | 8 +- lib/relay/protocol/packets.go | 3 +- script/next-version.go | 4 +- script/prune_mocks.go | 2 +- tools.go | 15 --- 21 files changed, 21 insertions(+), 305 deletions(-) delete mode 100644 tools.go diff --git a/go.mod b/go.mod index 4e4970dcb..25faea2ab 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,6 @@ require ( github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/maruel/panicparse/v2 v2.5.0 github.com/mattn/go-sqlite3 v1.14.31 - github.com/maxbrunsfeld/counterfeiter/v6 v6.11.3 github.com/maxmind/geoipupdate/v6 v6.1.0 github.com/miscreant/miscreant.go v0.0.0-20200214223636-26d376326b75 github.com/oschwald/geoip2-golang v1.13.0 @@ -49,7 +48,6 @@ require ( golang.org/x/sys v0.35.0 golang.org/x/text v0.28.0 golang.org/x/time v0.12.0 - golang.org/x/tools v0.36.0 google.golang.org/protobuf v1.36.7 modernc.org/sqlite v1.38.2 sigs.k8s.io/yaml v1.6.0 @@ -79,6 +77,7 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/maxbrunsfeld/counterfeiter/v6 v6.11.3 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/ncruces/go-strftime v0.1.9 // indirect github.com/nxadm/tail v1.4.11 // indirect @@ -103,6 +102,7 @@ require ( go.yaml.in/yaml/v2 v2.4.2 // indirect golang.org/x/mod v0.27.0 // indirect golang.org/x/sync v0.16.0 // indirect + golang.org/x/tools v0.36.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect modernc.org/libc v1.66.3 // indirect modernc.org/mathutil v1.7.1 // indirect @@ -114,3 +114,9 @@ replace github.com/gobwas/glob v0.2.3 => github.com/calmh/glob v0.0.0-2022061508 // https://github.com/mattn/go-sqlite3/pull/1338 replace github.com/mattn/go-sqlite3 v1.14.31 => github.com/calmh/go-sqlite3 v1.14.32-0.20250812195006-80712c77b76a + +tool ( + github.com/calmh/xdr/cmd/genxdr + github.com/maxbrunsfeld/counterfeiter/v6 + golang.org/x/tools/cmd/goimports +) diff --git a/lib/config/mocks/mocked_wrapper.go b/lib/config/mocks/mocked_wrapper.go index 28dadba41..2f8726bf8 100644 --- a/lib/config/mocks/mocked_wrapper.go +++ b/lib/config/mocks/mocked_wrapper.go @@ -1809,60 +1809,6 @@ func (fake *Wrapper) UnsubscribeArgsForCall(i int) config.Committer { func (fake *Wrapper) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.configPathMutex.RLock() - defer fake.configPathMutex.RUnlock() - fake.defaultDeviceMutex.RLock() - defer fake.defaultDeviceMutex.RUnlock() - fake.defaultFolderMutex.RLock() - defer fake.defaultFolderMutex.RUnlock() - fake.defaultIgnoresMutex.RLock() - defer fake.defaultIgnoresMutex.RUnlock() - fake.deviceMutex.RLock() - defer fake.deviceMutex.RUnlock() - fake.deviceListMutex.RLock() - defer fake.deviceListMutex.RUnlock() - fake.devicesMutex.RLock() - defer fake.devicesMutex.RUnlock() - fake.folderMutex.RLock() - defer fake.folderMutex.RUnlock() - fake.folderListMutex.RLock() - defer fake.folderListMutex.RUnlock() - fake.folderPasswordsMutex.RLock() - defer fake.folderPasswordsMutex.RUnlock() - fake.foldersMutex.RLock() - defer fake.foldersMutex.RUnlock() - fake.gUIMutex.RLock() - defer fake.gUIMutex.RUnlock() - fake.ignoredDeviceMutex.RLock() - defer fake.ignoredDeviceMutex.RUnlock() - fake.ignoredDevicesMutex.RLock() - defer fake.ignoredDevicesMutex.RUnlock() - fake.ignoredFolderMutex.RLock() - defer fake.ignoredFolderMutex.RUnlock() - fake.lDAPMutex.RLock() - defer fake.lDAPMutex.RUnlock() - fake.modifyMutex.RLock() - defer fake.modifyMutex.RUnlock() - fake.myIDMutex.RLock() - defer fake.myIDMutex.RUnlock() - fake.optionsMutex.RLock() - defer fake.optionsMutex.RUnlock() - fake.rawCopyMutex.RLock() - defer fake.rawCopyMutex.RUnlock() - fake.removeDeviceMutex.RLock() - defer fake.removeDeviceMutex.RUnlock() - fake.removeFolderMutex.RLock() - defer fake.removeFolderMutex.RUnlock() - fake.requiresRestartMutex.RLock() - defer fake.requiresRestartMutex.RUnlock() - fake.saveMutex.RLock() - defer fake.saveMutex.RUnlock() - fake.serveMutex.RLock() - defer fake.serveMutex.RUnlock() - fake.subscribeMutex.RLock() - defer fake.subscribeMutex.RUnlock() - fake.unsubscribeMutex.RLock() - defer fake.unsubscribeMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/lib/config/wrapper.go b/lib/config/wrapper.go index e5120b003..d2e9f1b8c 100644 --- a/lib/config/wrapper.go +++ b/lib/config/wrapper.go @@ -4,8 +4,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can obtain one at https://mozilla.org/MPL/2.0/. -//go:generate -command counterfeiter go run github.com/maxbrunsfeld/counterfeiter/v6 -//go:generate counterfeiter -o mocks/mocked_wrapper.go --fake-name Wrapper . Wrapper +//go:generate go tool counterfeiter -o mocks/mocked_wrapper.go --fake-name Wrapper . Wrapper package config diff --git a/lib/connections/mocks/service.go b/lib/connections/mocks/service.go index 70b967d6b..39f70ec3b 100644 --- a/lib/connections/mocks/service.go +++ b/lib/connections/mocks/service.go @@ -403,18 +403,6 @@ func (fake *Service) ServeReturnsOnCall(i int, result1 error) { func (fake *Service) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.allAddressesMutex.RLock() - defer fake.allAddressesMutex.RUnlock() - fake.connectionStatusMutex.RLock() - defer fake.connectionStatusMutex.RUnlock() - fake.externalAddressesMutex.RLock() - defer fake.externalAddressesMutex.RUnlock() - fake.listenerStatusMutex.RLock() - defer fake.listenerStatusMutex.RUnlock() - fake.nATTypeMutex.RLock() - defer fake.nATTypeMutex.RUnlock() - fake.serveMutex.RLock() - defer fake.serveMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/lib/connections/service.go b/lib/connections/service.go index bd16be990..c72222b84 100644 --- a/lib/connections/service.go +++ b/lib/connections/service.go @@ -4,8 +4,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can obtain one at https://mozilla.org/MPL/2.0/. -//go:generate -command counterfeiter go run github.com/maxbrunsfeld/counterfeiter/v6 -//go:generate counterfeiter -o mocks/service.go --fake-name Service . Service +//go:generate go tool counterfeiter -o mocks/service.go --fake-name Service . Service package connections diff --git a/lib/discover/manager.go b/lib/discover/manager.go index bf0025eb1..8370a9405 100644 --- a/lib/discover/manager.go +++ b/lib/discover/manager.go @@ -4,8 +4,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can obtain one at https://mozilla.org/MPL/2.0/. -//go:generate -command counterfeiter go run github.com/maxbrunsfeld/counterfeiter/v6 -//go:generate counterfeiter -o mocks/manager.go --fake-name Manager . Manager +//go:generate go tool counterfeiter -o mocks/manager.go --fake-name Manager . Manager package discover diff --git a/lib/discover/mocks/manager.go b/lib/discover/mocks/manager.go index 12982ad25..55323f4f6 100644 --- a/lib/discover/mocks/manager.go +++ b/lib/discover/mocks/manager.go @@ -420,18 +420,6 @@ func (fake *Manager) StringReturnsOnCall(i int, result1 string) { func (fake *Manager) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.cacheMutex.RLock() - defer fake.cacheMutex.RUnlock() - fake.childErrorsMutex.RLock() - defer fake.childErrorsMutex.RUnlock() - fake.errorMutex.RLock() - defer fake.errorMutex.RUnlock() - fake.lookupMutex.RLock() - defer fake.lookupMutex.RUnlock() - fake.serveMutex.RLock() - defer fake.serveMutex.RUnlock() - fake.stringMutex.RLock() - defer fake.stringMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/lib/events/events.go b/lib/events/events.go index 1650098b1..8b5df3e0b 100644 --- a/lib/events/events.go +++ b/lib/events/events.go @@ -4,8 +4,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can obtain one at https://mozilla.org/MPL/2.0/. -//go:generate -command counterfeiter go run github.com/maxbrunsfeld/counterfeiter/v6 -//go:generate counterfeiter -o mocks/buffered_subscription.go --fake-name BufferedSubscription . BufferedSubscription +//go:generate go tool counterfeiter -o mocks/buffered_subscription.go --fake-name BufferedSubscription . BufferedSubscription // Package events provides event subscription and polling functionality. package events diff --git a/lib/events/mocks/buffered_subscription.go b/lib/events/mocks/buffered_subscription.go index 5c7090df5..4eec8f250 100644 --- a/lib/events/mocks/buffered_subscription.go +++ b/lib/events/mocks/buffered_subscription.go @@ -160,10 +160,6 @@ func (fake *BufferedSubscription) SinceReturnsOnCall(i int, result1 []events.Eve func (fake *BufferedSubscription) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.maskMutex.RLock() - defer fake.maskMutex.RUnlock() - fake.sinceMutex.RLock() - defer fake.sinceMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/lib/model/folder_summary.go b/lib/model/folder_summary.go index 494433231..40772ae1e 100644 --- a/lib/model/folder_summary.go +++ b/lib/model/folder_summary.go @@ -4,8 +4,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can obtain one at https://mozilla.org/MPL/2.0/. -//go:generate -command counterfeiter go run github.com/maxbrunsfeld/counterfeiter/v6 -//go:generate counterfeiter -o mocks/folderSummaryService.go --fake-name FolderSummaryService . FolderSummaryService +//go:generate go tool counterfeiter -o mocks/folderSummaryService.go --fake-name FolderSummaryService . FolderSummaryService package model diff --git a/lib/model/mocks/folderSummaryService.go b/lib/model/mocks/folderSummaryService.go index 85340bee3..b71feac86 100644 --- a/lib/model/mocks/folderSummaryService.go +++ b/lib/model/mocks/folderSummaryService.go @@ -165,10 +165,6 @@ func (fake *FolderSummaryService) SummaryReturnsOnCall(i int, result1 *model.Fol func (fake *FolderSummaryService) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.serveMutex.RLock() - defer fake.serveMutex.RUnlock() - fake.summaryMutex.RLock() - defer fake.summaryMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/lib/model/mocks/model.go b/lib/model/mocks/model.go index cdceb850e..df3947587 100644 --- a/lib/model/mocks/model.go +++ b/lib/model/mocks/model.go @@ -3837,112 +3837,6 @@ func (fake *Model) WatchErrorReturnsOnCall(i int, result1 error) { func (fake *Model) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.addConnectionMutex.RLock() - defer fake.addConnectionMutex.RUnlock() - fake.allGlobalFilesMutex.RLock() - defer fake.allGlobalFilesMutex.RUnlock() - fake.availabilityMutex.RLock() - defer fake.availabilityMutex.RUnlock() - fake.bringToFrontMutex.RLock() - defer fake.bringToFrontMutex.RUnlock() - fake.closedMutex.RLock() - defer fake.closedMutex.RUnlock() - fake.clusterConfigMutex.RLock() - defer fake.clusterConfigMutex.RUnlock() - fake.completionMutex.RLock() - defer fake.completionMutex.RUnlock() - fake.connectedToMutex.RLock() - defer fake.connectedToMutex.RUnlock() - fake.connectionStatsMutex.RLock() - defer fake.connectionStatsMutex.RUnlock() - fake.currentFolderFileMutex.RLock() - defer fake.currentFolderFileMutex.RUnlock() - fake.currentGlobalFileMutex.RLock() - defer fake.currentGlobalFileMutex.RUnlock() - fake.currentIgnoresMutex.RLock() - defer fake.currentIgnoresMutex.RUnlock() - fake.delayScanMutex.RLock() - defer fake.delayScanMutex.RUnlock() - fake.deviceStatisticsMutex.RLock() - defer fake.deviceStatisticsMutex.RUnlock() - fake.dismissPendingDeviceMutex.RLock() - defer fake.dismissPendingDeviceMutex.RUnlock() - fake.dismissPendingFolderMutex.RLock() - defer fake.dismissPendingFolderMutex.RUnlock() - fake.downloadProgressMutex.RLock() - defer fake.downloadProgressMutex.RUnlock() - fake.folderErrorsMutex.RLock() - defer fake.folderErrorsMutex.RUnlock() - fake.folderProgressBytesCompletedMutex.RLock() - defer fake.folderProgressBytesCompletedMutex.RUnlock() - fake.folderStatisticsMutex.RLock() - defer fake.folderStatisticsMutex.RUnlock() - fake.getFolderVersionsMutex.RLock() - defer fake.getFolderVersionsMutex.RUnlock() - fake.globalDirectoryTreeMutex.RLock() - defer fake.globalDirectoryTreeMutex.RUnlock() - fake.globalSizeMutex.RLock() - defer fake.globalSizeMutex.RUnlock() - fake.indexMutex.RLock() - defer fake.indexMutex.RUnlock() - fake.indexUpdateMutex.RLock() - defer fake.indexUpdateMutex.RUnlock() - fake.loadIgnoresMutex.RLock() - defer fake.loadIgnoresMutex.RUnlock() - fake.localChangedFolderFilesMutex.RLock() - defer fake.localChangedFolderFilesMutex.RUnlock() - fake.localFilesMutex.RLock() - defer fake.localFilesMutex.RUnlock() - fake.localFilesSequencedMutex.RLock() - defer fake.localFilesSequencedMutex.RUnlock() - fake.localSizeMutex.RLock() - defer fake.localSizeMutex.RUnlock() - fake.needFolderFilesMutex.RLock() - defer fake.needFolderFilesMutex.RUnlock() - fake.needSizeMutex.RLock() - defer fake.needSizeMutex.RUnlock() - fake.onHelloMutex.RLock() - defer fake.onHelloMutex.RUnlock() - fake.overrideMutex.RLock() - defer fake.overrideMutex.RUnlock() - fake.pendingDevicesMutex.RLock() - defer fake.pendingDevicesMutex.RUnlock() - fake.pendingFoldersMutex.RLock() - defer fake.pendingFoldersMutex.RUnlock() - fake.receiveOnlySizeMutex.RLock() - defer fake.receiveOnlySizeMutex.RUnlock() - fake.remoteNeedFolderFilesMutex.RLock() - defer fake.remoteNeedFolderFilesMutex.RUnlock() - fake.remoteSequencesMutex.RLock() - defer fake.remoteSequencesMutex.RUnlock() - fake.requestMutex.RLock() - defer fake.requestMutex.RUnlock() - fake.requestGlobalMutex.RLock() - defer fake.requestGlobalMutex.RUnlock() - fake.resetFolderMutex.RLock() - defer fake.resetFolderMutex.RUnlock() - fake.restoreFolderVersionsMutex.RLock() - defer fake.restoreFolderVersionsMutex.RUnlock() - fake.revertMutex.RLock() - defer fake.revertMutex.RUnlock() - fake.scanFolderMutex.RLock() - defer fake.scanFolderMutex.RUnlock() - fake.scanFolderSubdirsMutex.RLock() - defer fake.scanFolderSubdirsMutex.RUnlock() - fake.scanFoldersMutex.RLock() - defer fake.scanFoldersMutex.RUnlock() - fake.sequenceMutex.RLock() - defer fake.sequenceMutex.RUnlock() - fake.serveMutex.RLock() - defer fake.serveMutex.RUnlock() - fake.setIgnoresMutex.RLock() - defer fake.setIgnoresMutex.RUnlock() - fake.stateMutex.RLock() - defer fake.stateMutex.RUnlock() - fake.usageReportingStatsMutex.RLock() - defer fake.usageReportingStatsMutex.RUnlock() - fake.watchErrorMutex.RLock() - defer fake.watchErrorMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/lib/model/model.go b/lib/model/model.go index 331acaed1..43ff023c6 100644 --- a/lib/model/model.go +++ b/lib/model/model.go @@ -4,8 +4,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can obtain one at https://mozilla.org/MPL/2.0/. -//go:generate -command counterfeiter go run github.com/maxbrunsfeld/counterfeiter/v6 -//go:generate counterfeiter -o mocks/model.go --fake-name Model . Model +//go:generate go tool counterfeiter -o mocks/model.go --fake-name Model . Model package model diff --git a/lib/protocol/mocked_connection_info_test.go b/lib/protocol/mocked_connection_info_test.go index 85f46871c..3b960340d 100644 --- a/lib/protocol/mocked_connection_info_test.go +++ b/lib/protocol/mocked_connection_info_test.go @@ -582,24 +582,6 @@ func (fake *mockedConnectionInfo) TypeReturnsOnCall(i int, result1 string) { func (fake *mockedConnectionInfo) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.connectionIDMutex.RLock() - defer fake.connectionIDMutex.RUnlock() - fake.cryptoMutex.RLock() - defer fake.cryptoMutex.RUnlock() - fake.establishedAtMutex.RLock() - defer fake.establishedAtMutex.RUnlock() - fake.isLocalMutex.RLock() - defer fake.isLocalMutex.RUnlock() - fake.priorityMutex.RLock() - defer fake.priorityMutex.RUnlock() - fake.remoteAddrMutex.RLock() - defer fake.remoteAddrMutex.RUnlock() - fake.stringMutex.RLock() - defer fake.stringMutex.RUnlock() - fake.transportMutex.RLock() - defer fake.transportMutex.RUnlock() - fake.typeMutex.RLock() - defer fake.typeMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/lib/protocol/mocks/connection.go b/lib/protocol/mocks/connection.go index c54fec5e1..af5a0dde6 100644 --- a/lib/protocol/mocks/connection.go +++ b/lib/protocol/mocks/connection.go @@ -1144,44 +1144,6 @@ func (fake *Connection) TypeReturnsOnCall(i int, result1 string) { func (fake *Connection) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.closeMutex.RLock() - defer fake.closeMutex.RUnlock() - fake.closedMutex.RLock() - defer fake.closedMutex.RUnlock() - fake.clusterConfigMutex.RLock() - defer fake.clusterConfigMutex.RUnlock() - fake.connectionIDMutex.RLock() - defer fake.connectionIDMutex.RUnlock() - fake.cryptoMutex.RLock() - defer fake.cryptoMutex.RUnlock() - fake.deviceIDMutex.RLock() - defer fake.deviceIDMutex.RUnlock() - fake.downloadProgressMutex.RLock() - defer fake.downloadProgressMutex.RUnlock() - fake.establishedAtMutex.RLock() - defer fake.establishedAtMutex.RUnlock() - fake.indexMutex.RLock() - defer fake.indexMutex.RUnlock() - fake.indexUpdateMutex.RLock() - defer fake.indexUpdateMutex.RUnlock() - fake.isLocalMutex.RLock() - defer fake.isLocalMutex.RUnlock() - fake.priorityMutex.RLock() - defer fake.priorityMutex.RUnlock() - fake.remoteAddrMutex.RLock() - defer fake.remoteAddrMutex.RUnlock() - fake.requestMutex.RLock() - defer fake.requestMutex.RUnlock() - fake.startMutex.RLock() - defer fake.startMutex.RUnlock() - fake.statisticsMutex.RLock() - defer fake.statisticsMutex.RUnlock() - fake.stringMutex.RLock() - defer fake.stringMutex.RUnlock() - fake.transportMutex.RLock() - defer fake.transportMutex.RUnlock() - fake.typeMutex.RLock() - defer fake.typeMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/lib/protocol/mocks/connection_info.go b/lib/protocol/mocks/connection_info.go index 5f176fc38..73c1224e0 100644 --- a/lib/protocol/mocks/connection_info.go +++ b/lib/protocol/mocks/connection_info.go @@ -584,24 +584,6 @@ func (fake *ConnectionInfo) TypeReturnsOnCall(i int, result1 string) { func (fake *ConnectionInfo) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.connectionIDMutex.RLock() - defer fake.connectionIDMutex.RUnlock() - fake.cryptoMutex.RLock() - defer fake.cryptoMutex.RUnlock() - fake.establishedAtMutex.RLock() - defer fake.establishedAtMutex.RUnlock() - fake.isLocalMutex.RLock() - defer fake.isLocalMutex.RUnlock() - fake.priorityMutex.RLock() - defer fake.priorityMutex.RUnlock() - fake.remoteAddrMutex.RLock() - defer fake.remoteAddrMutex.RUnlock() - fake.stringMutex.RLock() - defer fake.stringMutex.RUnlock() - fake.transportMutex.RLock() - defer fake.transportMutex.RUnlock() - fake.typeMutex.RLock() - defer fake.typeMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/lib/protocol/protocol.go b/lib/protocol/protocol.go index 9f5df13c1..8d47d4948 100644 --- a/lib/protocol/protocol.go +++ b/lib/protocol/protocol.go @@ -4,14 +4,12 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can obtain one at https://mozilla.org/MPL/2.0/. -//go:generate -command counterfeiter go run github.com/maxbrunsfeld/counterfeiter/v6 - // Prevents import loop, for internal testing -//go:generate counterfeiter -o mocked_connection_info_test.go --fake-name mockedConnectionInfo . ConnectionInfo +//go:generate go tool counterfeiter -o mocked_connection_info_test.go --fake-name mockedConnectionInfo . ConnectionInfo //go:generate go run ../../script/prune_mocks.go -t mocked_connection_info_test.go -//go:generate counterfeiter -o mocks/connection_info.go --fake-name ConnectionInfo . ConnectionInfo -//go:generate counterfeiter -o mocks/connection.go --fake-name Connection . Connection +//go:generate go tool counterfeiter -o mocks/connection_info.go --fake-name ConnectionInfo . ConnectionInfo +//go:generate go tool counterfeiter -o mocks/connection.go --fake-name Connection . Connection package protocol diff --git a/lib/relay/protocol/packets.go b/lib/relay/protocol/packets.go index 926d856a9..61dc1b63d 100644 --- a/lib/relay/protocol/packets.go +++ b/lib/relay/protocol/packets.go @@ -1,7 +1,6 @@ // Copyright (C) 2015 Audrius Butkevicius and Contributors (see the CONTRIBUTORS file). -//go:generate -command genxdr go run github.com/calmh/xdr/cmd/genxdr -//go:generate genxdr -o packets_xdr.go packets.go +//go:generate go tool genxdr -o packets_xdr.go packets.go package protocol diff --git a/script/next-version.go b/script/next-version.go index b35ec41b8..2a24906c7 100644 --- a/script/next-version.go +++ b/script/next-version.go @@ -4,8 +4,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can obtain one at https://mozilla.org/MPL/2.0/. -//go:build ignore -// +build ignore +//go:build tools +// +build tools package main diff --git a/script/prune_mocks.go b/script/prune_mocks.go index ab56c3e08..ac8815f13 100644 --- a/script/prune_mocks.go +++ b/script/prune_mocks.go @@ -35,7 +35,7 @@ func main() { if err != nil { log.Fatal(err) } - err = exec.Command("go", "run", "golang.org/x/tools/cmd/goimports", "-w", path).Run() + err = exec.Command("go", "tool", "goimports", "-w", path).Run() if err != nil { log.Fatal(err) } diff --git a/tools.go b/tools.go deleted file mode 100644 index 111b11fa3..000000000 --- a/tools.go +++ /dev/null @@ -1,15 +0,0 @@ -// This file is never built. It serves to establish dependencies on tools -// used by go generate and build.go. See -// https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module - -//go:build tools -// +build tools - -package tools - -import ( - _ "github.com/calmh/xdr" - _ "github.com/coreos/go-semver/semver" - _ "github.com/maxbrunsfeld/counterfeiter/v6" - _ "golang.org/x/tools/cmd/goimports" -)