Skip to content

assignment copies lock value to igd: IGDService contains Service (with sync.RWMutex) #10426

Closed

Description

@zhmlst

What happened?

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.

Syncthing version

v2.0.10

Platform & operating system

Linux x86_64

Browser version

Mozilla Firefox 143.0.4

Relevant log output

Activity

  1. added theissue type on Oct 12, 2025
  2. added
    bug
    needs-triage
    on Oct 12, 2025
  3. removed
    needs-triage
    on Oct 12, 2025
  4. imsodin commented on Oct 12, 2025

    @imsodin
    Member

    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.

  5. added 2 commits that reference this issue on Oct 12, 2025
    b7ac229
    f9a39b6
  6. added a commit that references this issue on Oct 13, 2025
    20d2406
  7. added this to the v2.0.11 milestone on Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions