Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ var addDbMetadata = false
var flattenStrings = false

//FIXXX: should not be global
var keepXmlFirstLetterCase = true
// Default value should be false if it's _enabled_ with argument '-K'
var keepXmlFirstLetterCase = false

var lengthTagName = ""
var lengthTagPadding int64 = 0
Expand Down
2 changes: 1 addition & 1 deletion node.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (n *Node) renderSpaceTag() string {
if len(strings.TrimSpace(n.spaceTag)) == 0 {
return ""
} else {
return "__" + n.spaceTag
return capitalizeFirstLetter(n.spaceTag)
}
}

Expand Down
5 changes: 4 additions & 1 deletion printGoStructVisitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ func print(v *PrintGoStructVisitor, node *Node) error {
}

attributes := v.globalTagAttributes[nk(node)]
typeName := node.makeType(namePrefix, nameSuffix)

//v.lineChannel <- "type " + node.makeType(namePrefix, nameSuffix) + " struct {"
fmt.Fprintln(v.writer, "type "+node.makeType(namePrefix, nameSuffix)+" struct {")
fmt.Fprintln(v.writer, "// "+typeName+" has been generated by chidley.")
fmt.Fprintln(v.writer, "type "+typeName+" struct {")

// fmt.Fprintln(v.writer, "\tXMLName xml.Name`"+makeXmlAnnotation(node.space, false, node.name)+" "+makeJsonAnnotation(node.spaceTag, false, node.name)+"`")

Expand Down
16 changes: 10 additions & 6 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,16 @@ func makeAttributes(writer io.Writer, attributes []*FQN, nameSpaceTagMap map[str
}

func goVariableNameSanitize(s string) string {
s = strings.Replace(s, ":", "_colon_", -1)
s = strings.Replace(s, "/", "_slash_", -1)
s = strings.Replace(s, ".", "_dot_", -1)
s = strings.Replace(s, "-", "_dash_", -1)
s = strings.Replace(s, " ", "_space_", -1)
s = strings.Replace(s, "-", "_dash_", -1)
s = strings.Replace(s, ":", "Colon", -1)
s = strings.Replace(s, "/", "Slash", -1)
s = strings.Replace(s, ".", "Dot", -1)
s = strings.Replace(s, "-", "Dash", -1)
s = strings.Replace(s, " ", "Space", -1)
s = strings.Replace(s, "-", "Dash", -1)
// TODO: create better checks if the following words/abbreviations are really standalone, and not only substrings of another word
s = strings.Replace(s, "Id", "ID", -1)
s = strings.Replace(s, "Api", "API", -1)
s = strings.Replace(s, "Http", "HTTP", -1)

return s
}
Expand Down