-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: spec: require tagged literals for external structs #2794
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
Comments
At present there is a vet check for this:
Is there an advantage to promoting this check to the language level? |
There might be scenarios where it's tedious to have to repeat struct field names over and over again; e.g., for small structs that are frequently created and won't change. Example p := graphic.Point3D{1, 2, 3} But for cases like these it's always easy (and probably better) to provide any factory function instead. |
There is a trick to force users of an exported struct to write field names:
And for any usage of
(source: https://groups.google.com/forum/#!topic/golang-nuts/NSjVW82i0mY) |
As this is checked by vet today, it does not seem necessary to add to the language proper. (Perhaps at some future point we should consider promoting some vet checks into the language proper.) |
The text was updated successfully, but these errors were encountered: