xuri / xgen

XSD (XML Schema Definition) parser and Go/C/Java/Rust/TypeScript code generator
BSD 3-Clause "New" or "Revised" License
335 stars 78 forks source link

Go language generation for xsd:integer produces wrong code #10

Open ooxi opened 4 years ago

ooxi commented 4 years ago

Description

Generating a binding for an XML Schema containing xsd:integer will result in int. This is an error since xsd:integer is unbounded while the Go type int is a 32-bit signed integer

Steps to reproduce the issue:

  1. Create an XML schema containing an element of type xsd:integer (assuming xmlns:xsd="http://www.w3.org/2001/XMLSchema")
  2. Execute xgen -i myschema.xsd -o myoutput -l Go
  3. Look at the generated myoutput/myschema.xsd.go

Describe the results you received:

type MyType struct {
    Id         int    `xml:"id"`
}

Describe the results you expected:

type MyType struct {
    Id         Int    `xml:"id"`
}

I'm not a Go expert, but I would have expected a type which can represent arbitrary integer values. Maybe big.Int?

Output of go version:

go version go1.15.1 linux/arm

Aurora version or commit ID:

???

Sorry, I don't know aurora

Environment details (OS, physical, etc.):

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic