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
{{ message }}
Repository navigation
assignment copies lock value to igd: IGDService contains Service (with sync.RWMutex) #10426
What happened
The function discover returns a slice of IGDService structs. IGDService contains a nat.Service, which contains a sync.RWMutex.
Iterating over the slice with for _, igd := range igds copies the structure, including the RWMutex.
Go linters (e.g., go vet) report: assignment copies lock value to igd: IGDService contains Service with sync.RWMutex.
What I expected instead
To avoid copying the mutex, the function could return []*IGDService instead of []IGDService.
Environment
Syncthing version: v2.0.10
OS: Linux x86_64
Additional info
All existing tests pass with the proposed change.
I thought go test also did the equivalent of go vet, but turns out only for a subset of rules. And apparently this one isn't in that set. We probably should run tests with -vet=all.
Activity
imsodin commentedon Oct 12, 2025
I thought
go testalso did the equivalent ofgo vet, but turns out only for a subset of rules. And apparently this one isn't in that set. We probably should run tests with-vet=all.fix(unpn): Remove incorrect embedding of nat.Service (fixes syncthing…
fix(unpn): Remove incorrect embedding of nat.Service (fixes syncthing…
chore(upnp): remove incorrect embedding of nat.Service (fixes syncthi…