Skip to content

avoid copying structures with embedded mutexs#7571

Merged
jinzhu merged 1 commit intogo-gorm:masterfrom
drakkan:copylocks
Aug 28, 2025
Merged

avoid copying structures with embedded mutexs#7571
jinzhu merged 1 commit intogo-gorm:masterfrom
drakkan:copylocks

Conversation

@drakkan
Copy link
Copy Markdown
Contributor

@drakkan drakkan commented Aug 27, 2025

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

Fixes warning like this:

assignment copies lock value to relationships:
gorm.io/gorm/schema.Relationships contains sync.RWMutex

Fixes warning like this:

assignment copies lock value to relationships:
gorm.io/gorm/schema.Relationships contains sync.RWMutex
@propel-code-bot
Copy link
Copy Markdown
Contributor

This pull request addresses Golang warnings related to copying structures containing embedded mutexes, specifically sync.RWMutex within gorm.io/gorm/schema.Relationships. Changes ensure that objects with embedded mutexes are passed by reference rather than by value, preventing unsafe lock copying and eliminating the related compiler warning. Several test helper function signatures were also updated from value types to pointer types to align with these safety improvements.

This summary was automatically generated by @propel-code-bot

@jinzhu jinzhu merged commit cace4a6 into go-gorm:master Aug 28, 2025
26 checks passed
mackinleysmith pushed a commit to mackinleysmith/gorm that referenced this pull request Sep 8, 2025
Fixes warning like this:

assignment copies lock value to relationships:
gorm.io/gorm/schema.Relationships contains sync.RWMutex
phroggyy pushed a commit to incident-io/gorm that referenced this pull request Jan 23, 2026
Fixes warning like this:

assignment copies lock value to relationships:
gorm.io/gorm/schema.Relationships contains sync.RWMutex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants