-
Notifications
You must be signed in to change notification settings - Fork 246
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
go: no runtime indication that a required field in a struct is not supplied #2672
Closed
1 of 5 tasks
Labels
bug
This issue is a bug.
effort/small
Small work item – less than a day of effort
language/go
Regarding GoLang bindings
p2
Comments
eladb
added
bug
This issue is a bug.
needs-triage
This issue or PR still needs to be triaged.
labels
Mar 10, 2021
eladb
changed the title
go: no indication that a required field in a struct is not supplied
go: no runtime indication that a required field in a struct is not supplied
Mar 11, 2021
MrArnoldPalmer
added
language/go
Regarding GoLang bindings
effort/small
Small work item – less than a day of effort
p2
and removed
needs-triage
This issue or PR still needs to be triaged.
labels
Mar 30, 2021
5 tasks
7 tasks
RomainMuller
added a commit
that referenced
this issue
Apr 11, 2022
RomainMuller
added a commit
that referenced
this issue
Apr 11, 2022
RomainMuller
added a commit
that referenced
this issue
Apr 25, 2022
Adds a `field:"required"` or `field:"optional"` tag on struct fields to denote whether they are required or optional (obviously). This is a cheap-ass way to provide documentation visibility to users. This isn't perfect as ideally, one would want compile-time enforcement of these, however this isn't currently posisble with Go (we explored several options, including via the use of generics, but it did not end up with any particularly improved solution). This does however include runtime enforcement with a dedicated error message. Fixes #2536 Fixes #2672
Repository owner
moved this from In Review
to Done
in CDK Go General Availability
Apr 25, 2022
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
This issue is a bug.
effort/small
Small work item – less than a day of effort
language/go
Regarding GoLang bindings
p2
🐛 Bug Report
Affected Languages
GoLang
TypeScript
orJavascript
Python
Java
C#
,F#
, ...)General Information
What is the problem?
Consider a jsii struct with a required field:
In go it is possible to initialize it without specifying a value for
required
:It is impossible to tell which fields are required #2536, but at least we should get a panic if this object is passed to JS without the required fields set:
See compliance test
TestStructs_containsNullChecks
.The text was updated successfully, but these errors were encountered: