We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When using struct with fields as type parameters the Type does not have the fields from the struct
func GetName[Type ~struct{ Name string }](obj Type) string { return obj.Name }
One must cast it to an other struct type in order to get access to that fields
func GetName[Type ~struct{ Name string }](obj Type) string { converted := (struct{Name string})(obj) return converted.Name }
Proposal to have fileds direct on type parameters without need for conversion
The text was updated successfully, but these errors were encountered:
#48522
Sorry, something went wrong.
More specific: #51576
This is just one restriction of the current Go generics.
No branches or pull requests
Proposal Details
When using struct with fields as type parameters the Type does not have the fields from the struct
One must cast it to an other struct type in order to get access to that fields
Proposal to have fileds direct on type parameters without need for conversion
The text was updated successfully, but these errors were encountered: