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

Can generate structs with unexported fields #198

Open
ieure opened this issue Mar 26, 2021 · 2 comments
Open

Can generate structs with unexported fields #198

ieure opened this issue Mar 26, 2021 · 2 comments

Comments

@ieure
Copy link
Contributor

ieure commented Mar 26, 2021

I have a WSDL with this element:

<xsd:element name="_24_Hour_Shift" type="xsd:boolean" minOccurs="0" maxOccurs="1">

gowsdl produces this struct field:

_24_Hour_Shift bool `xml:"_24_Hour_Shift,omitempty" json:"_24_Hour_Shift,omitempty"`

Since the first char isn't capitalized, the field isn't exported, and can't be used.

This gets flagged by my Bazel nogo rules as well:

compilepkg: nogo: errors found by nogo during build-time code analysis:
lib/…/client.go:17767:2: struct field _24_Hour_Shift has json tag but is not exported (structtag)
@MKITConsulting
Copy link

Just rename the variable in your case to "Hour_Shift_24" but keep the xml and json tag description. Then the struct field will be exported (as is capitalized) as desired but mapped back to "_24_Hour_Shift".

@ieure
Copy link
Contributor Author

ieure commented Apr 12, 2021

Just rename the variable in your case to "Hour_Shift_24" but keep the xml and json tag description. Then the struct field will be exported (as is capitalized) as desired but mapped back to "_24_Hour_Shift".

Yes, as a purely pragmatic matter, I have already built a thing into our codegen process that automatically edits the file, even though the literal first line says "DO NOT EDIT." Since otherwise, the next time someone ran codegen, the change would be reverted.

The problem isn't "how can I fix the output," it's that gowsdl generates broken output in the first place. This is a bug report, not a StackOverflow question.

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

No branches or pull requests

2 participants