Skip to content

Commit

Permalink
allow for empty string in ToGoName
Browse files Browse the repository at this point in the history
  • Loading branch information
casualjim committed Jan 29, 2017
1 parent ccda4c1 commit d5f8ebc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
26 changes: 26 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

# Set default charset
[*.{js,py,go,scala,rb,java,html,css,less,sass,md}]
charset = utf-8

# Tab indentation (no size specified)
[*.go]
indent_style = tab

[*.md]
trim_trailing_whitespace = false

# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2
14 changes: 8 additions & 6 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,14 @@ func ToGoName(name string) string {
}

result := strings.Join(out, "")
ud := upper(result[:1])
ru := []rune(ud)
if unicode.IsUpper(ru[0]) {
result = ud + result[1:]
} else {
result = "X" + ud + result[1:]
if len(result) > 0 {
ud := upper(result[:1])
ru := []rune(ud)
if unicode.IsUpper(ru[0]) {
result = ud + result[1:]
} else {
result = "X" + ud + result[1:]
}
}
return result
}
Expand Down

0 comments on commit d5f8ebc

Please sign in to comment.