Closed neomantra closed 3 years ago
Where is Comp2.go being generated from this schema? Are there perhaps old files left behind?
Sorry, I had late-night pasted the wrong XML snippet when I was composing that.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sbe:messageSchema xmlns:sbe="http://fixprotocol.io/2016/sbe"
package="issue848"
id="1"
version="0"
semanticVersion="1.0"
description="test case 848 20210511"
byteOrder="littleEndian">
<types>
<composite name="Comp1" description="C1">
<type name="lmn" primitiveType="uint16"/>
<type name="wxy" primitiveType="uint16"/>
</composite>
<composite name="messageHeader" description="MH">
<type name="blockLength" primitiveType="uint16"/>
<type name="templateId" primitiveType="uint16"/>
<type name="schemaId" primitiveType="uint16"/>
<type name="version" primitiveType="uint16"/>
<ref name="c1" type="Comp1"/>
</composite>
<composite name="Comp2" description="C2">
<ref name="c1" type="Comp1"/>
</composite>
</types>
<sbe:message name="barmsg" id="4">
<field name="header" id="1" type="messageHeader"/>
<field name="c2" id="2" type="Comp2"/>
</sbe:message>
</sbe:messageSchema>
Test case file in my PR: https://github.com/real-logic/simple-binary-encoding/blob/f236400955bd2e436f40c40b1f51db8f965e7082/sbe-tool/src/test/resources/issue847.xml
When generating Go imports, the current implementation uses a single TreeSet to track the import names.
Golang is strict in imports and complains if an import is not used.
With some schema, excess imports are created and compilation fails.
Here's an example:
Which fails with the following error: