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

Created Go type but it was not used. #4

Open luizvnasc opened 4 years ago

luizvnasc commented 4 years ago

Description Xgen is creating a Go type for a element but the type was not used.

The xsd used is this one: e400101_v1.00.xsd.zip

Steps

$ go get -u github.com/xuri/xgen
go: github.com/xuri/xgen upgrade => v0.0.0-20200517172312-9d8630233132
go: finding module for package golang.org/x/net/html/charset
go: found golang.org/x/net/html/charset in golang.org/x/net v0.0.0-20200513185701-a91f0712d120
go: golang.org/x/text upgrade => v0.3.2
$ xgen -l Go -p evento -o ./v1.00/evento/ -i ./schemas/Evento_AlertaFisco_v1.01/e400101_v1.00.xsd
done

Describe the results you received:

type DetEvento struct {
    XMLName     xml.Name    `xml:"detEvento"`
    VersaoAttr  interface{} `xml:"versao,attr,omitempty"`
    DescEvento  *DescEvento `xml:"descEvento"`
    COrgaoAutor *TCodUfIBGE `xml:"cOrgaoAutor"`
    TpAutor     *TpAutor    `xml:"tpAutor"`
    VerAplic    *TVerAplic  `xml:"verAplic"`
    XObs        *XObs       `xml:"xObs"`
    MotivoCanc  *MotivoCanc `xml:"motivoCanc"`
    CPFOper     *TCpf       `xml:"CPFOper"`
    NomeOper    *NomeOper   `xml:"nomeOper"`
    RepOper     string      `xml:"repOper"`
}

// RepOper ...
type RepOper string

Describe the results you expected:

type DetEvento struct {
    XMLName     xml.Name    `xml:"detEvento"`
    VersaoAttr  interface{} `xml:"versao,attr,omitempty"`
    DescEvento  *DescEvento `xml:"descEvento"`
    COrgaoAutor *TCodUfIBGE `xml:"cOrgaoAutor"`
    TpAutor     *TpAutor    `xml:"tpAutor"`
    VerAplic    *TVerAplic  `xml:"verAplic"`
    XObs        *XObs       `xml:"xObs"`
    MotivoCanc  *MotivoCanc `xml:"motivoCanc"`
    CPFOper     *TCpf       `xml:"CPFOper"`
    NomeOper    *NomeOper   `xml:"nomeOper"`
    RepOper     RepOper      `xml:"repOper"`
}

// RepOper ...
type RepOper string

or

type DetEvento struct {
    XMLName     xml.Name    `xml:"detEvento"`
    VersaoAttr  interface{} `xml:"versao,attr,omitempty"`
    DescEvento  *DescEvento `xml:"descEvento"`
    COrgaoAutor *TCodUfIBGE `xml:"cOrgaoAutor"`
    TpAutor     *TpAutor    `xml:"tpAutor"`
    VerAplic    *TVerAplic  `xml:"verAplic"`
    XObs        *XObs       `xml:"xObs"`
    MotivoCanc  *MotivoCanc `xml:"motivoCanc"`
    CPFOper     *TCpf       `xml:"CPFOper"`
    NomeOper    *NomeOper   `xml:"nomeOper"`
    RepOper     string      `xml:"repOper"`
}

Output of go version:

go version go1.14.2 windows/amd64