diff --git a/genGo.go b/genGo.go index 057d53e..f0c4e16 100644 --- a/genGo.go +++ b/genGo.go @@ -303,7 +303,9 @@ func (gen *CodeGenerator) GoAttributeGroup(v *AttributeGroup) { // GoElement generates code for element XML schema in Go language syntax. func (gen *CodeGenerator) GoElement(v *Element) { - if _, ok := gen.StructAST[v.Name]; !ok { + // If v.Name == v.Type generating a type alias will reference itself + // and result in a duplicate type definition error from the go compiler + if _, ok := gen.StructAST[v.Name]; !ok && v.Name != v.Type { var plural string if v.Plural { plural = "[]" diff --git a/test/xsd/base64.xsd b/test/xsd/base64.xsd index 3fefe4d..854a1ba 100644 --- a/test/xsd/base64.xsd +++ b/test/xsd/base64.xsd @@ -1,4 +1,7 @@ - + + + @@ -8,7 +11,7 @@ - + @@ -16,39 +19,39 @@ - + - - - + + + - + - - + + - + - + @@ -64,10 +67,11 @@ - - + + + \ No newline at end of file