xuri / xgen

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

Does Nothing? #20

Closed webern closed 3 years ago

webern commented 3 years ago

Description

The program produces no output and exits zero saying "done". I wanted to debug this, but I had some issue with package name resolution.

Steps to reproduce the issue:

cat <<- "EOF" > schema.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
    targetNamespace="bks" xmlns="bks">
    <xs:element name="books">
        <xs:complexType>
            <xs:sequence maxOccurs="unbounded" minOccurs="0">
                <xs:element name="book" type="ctbook"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:complexType name="ctbook">
        <xs:sequence>
            <xs:element name="title" type="xs:string"/>
            <xs:element name="author" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
</xs:schema>
EOF
go get -u -v github.com/xuri/xgen/cmd/...
xgen -v
# xgen version: 0.1.0
xgen -i schema.xsd -o ./output -l Go
# done
ls -al output
# empty

Describe the results you received:

The output directory is empty.

Describe the results you expected:

Expected the program to produce some output.

Output of go version:

go version go1.14.1 darwin/amd64
webern commented 3 years ago

Edit: I figured out my debugging issue and was able to step through the code using GoLand. When I got to xmlFile, err = os.Open(opt.FilePath) (or maybe it was when the program started writing to a file) my mac raised a security dialogue to give the program access. When I did that, the program produced output as expected. So it seems my experience with silent failure might have been a macOS security thing. Catalina 10.15.7. It's too bad that an error doesn't seem to be raised there.