Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Each function passes the correct value or pointer to rules. #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dane
Copy link

@dane dane commented Dec 2, 2021

The combination of Elem().Interface() does not return a pointer, even if the original variable was a pointer. Passing by value to validation rules becomes a problem when the value is a struct with a private mutex. This is the case with structs generated with protoc-gen-go. go vet -copylocks illustrates the problem.

I acknowledge this may be a breaking change for some. If they have written custom rules, the rules receive an empty interface and have to cast the argument to the appropriate type. This argument will be a pointer in cases where it previously wasn't.

The combination of Elem().Interface() does not return a pointer, even if the
original variable was a pointer. Passing by value to validation rules becomes a
problem when the value is a struct with a private mutex. This is the case with
structs generated with protoc-gen-go. `go vet`'s copylocks check identifies the
problem.
@daneharrigan
Copy link

@qiangxue is this package still being maintained? I'm seeing several open PRs and there haven't been any commits in over a year.

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