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

Optional struct fields with struct types throwing errors in xsdgen #101

Open
nrlakin opened this issue Mar 21, 2020 · 1 comment · Fixed by #102
Open

Optional struct fields with struct types throwing errors in xsdgen #101

nrlakin opened this issue Mar 21, 2020 · 1 comment · Fixed by #102

Comments

@nrlakin
Copy link
Contributor

nrlakin commented Mar 21, 2020

I think this was introduced in #93 (I hit it merging #93 into my fork because I wanted optional structs to render as pointers).

Running xsdgen throws the following error:

error generating go structs from xsd: oadr2b/oadr2b_tmp.go:1114:16: expected type, found '&' (and 5 more errors) in package oadr2b

In the debug output that follows, I see the following struct rendered:

type X509DataType struct {
	Item             string                          `xml:",any"`
	X509IssuerSerial *X509IssuerSerialType           `xml:"http://www.w3.org/2000/09/xmldsig# X509IssuerSerial,omitempty"`
	X509SKI          *&{%!s(token.Pos=0) <nil> byte} `xml:"http://www.w3.org/2000/09/xmldsig# X509SKI,omitempty"`
	X509SubjectName  string                          `xml:"http://www.w3.org/2000/09/xmldsig# X509SubjectName,omitempty"`
	X509Certificate  *&{%!s(token.Pos=0) <nil> byte} `xml:"http://www.w3.org/2000/09/xmldsig# X509Certificate,omitempty"`
	X509CRL          *&{%!s(token.Pos=0) <nil> byte} `xml:"http://www.w3.org/2000/09/xmldsig# X509CRL,omitempty"`
}

I'm looking at it because I'd like the feature, but you may want to revert. I'll try to add a minimal schema to xsdgen/testdata that replicates the issue in any case.

@droyo
Copy link
Owner

droyo commented Mar 23, 2020

I've reverted. I think I can see the error here: https://github.com/elliots/go-xml/blob/2161665b1a098d50c305f0bf938f7aca2e05fee0/xsdgen/xsdgen.go#L697

I don't think that's the right way to construct a pointer using go/ast. I haven't tried yet but it should probably be something like this:

    base = ast.StarExpr{X: base}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants