Skip to content

Commit

Permalink
tweak struct naming for arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
coryb committed Aug 21, 2016
1 parent b582d9a commit 045a78f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions slipscheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,18 @@ func (s *SchemaProcessor) processSchema(schema *Schema) (typeName string, err er
if err != nil {
return "", err
}
if strings.Title(subTypeName) == subTypeName {
if strings.HasSuffix(subTypeName, "s") {
typeName = fmt.Sprintf("%ses", subTypeName)
} else {
typeName = fmt.Sprintf("%ss", subTypeName)

typeName = camelCase(schema.Name())
if typeName == "" {
if strings.Title(subTypeName) == subTypeName {
if strings.HasSuffix(subTypeName, "s") {
typeName = fmt.Sprintf("%ses", subTypeName)
} else {
typeName = fmt.Sprintf("%ss", subTypeName)
}
}
}
if typeName != "" {
typeName = strings.TrimPrefix(typeName, "*")
typeData := fmt.Sprintf("%stype %s []%s\n\n", s.structComment(schema, typeName), typeName, subTypeName)
if err := s.writeGoCode(typeName, typeData); err != nil {
Expand Down

0 comments on commit 045a78f

Please sign in to comment.