File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 "strings"
1010 "unicode"
1111
12+ "github.com/ettle/strcase"
1213 "github.com/fatih/camelcase"
13- "github.com/iancoleman/strcase"
1414)
1515
1616// ProperNouns is a set-style map that contains all of the proper
@@ -38,10 +38,9 @@ func AddProperNouns(nouns ...string) {
3838//
3939// This is a string in sentence case that I wrote in the USA with the help of Google
4040func Case (s string ) string {
41- // if we are not already in camel case, we convert to it
42- if strings .ContainsAny (s , "-_.\t " ) {
43- s = strcase .ToCamel (s )
44- }
41+ caser := strcase .NewCaser (false , nil , nil )
42+ s = caser .ToCase (s , strcase .TitleCase | strcase .PreserveInitialism , 0 )
43+
4544 words := camelcase .Split (s )
4645 for i , word := range words {
4746 // "I" is always capitalized
Original file line number Diff line number Diff line change 88 "testing"
99)
1010
11- func TestSentenceCase (t * testing.T ) {
11+ func TestCase (t * testing.T ) {
1212 AddProperNouns ("Google" )
1313 src := "thisIsAStringInSentenceCaseThatIWroteInTheUSAWithTheHelpOfGoogle"
1414 want := "This is a string in sentence case that I wrote in the USA with the help of Google"
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ require (
1010 github.com/aymerick/douceur v0.2.0
1111 github.com/chewxy/math32 v1.10.1
1212 github.com/ericchiang/css v1.3.0
13+ github.com/ettle/strcase v0.2.1-0.20230114185658-e5db6a6becf3
1314 github.com/fatih/camelcase v1.0.0
1415 github.com/fsnotify/fsnotify v1.7.0
1516 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240118000515-a250818d05e3
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq
3131github.com/dlclark/regexp2 v1.10.0 /go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8 =
3232github.com/ericchiang/css v1.3.0 h1:e0vS+vpujMjtT3/SYu7qTHn1LVzXWcLCCDjlfq3YlLY =
3333github.com/ericchiang/css v1.3.0 /go.mod h1:sVSdL+MFR9Q4cKJMQzpIkHIDOLiK+7Wmjjhq7D+MubA =
34+ github.com/ettle/strcase v0.2.1-0.20230114185658-e5db6a6becf3 h1:UveVPOxnOkBoelw2vLZTm+L0Z7fe/nz5d6JlY+A3QdE =
35+ github.com/ettle/strcase v0.2.1-0.20230114185658-e5db6a6becf3 /go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A =
3436github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8 =
3537github.com/fatih/camelcase v1.0.0 /go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc =
3638github.com/fsnotify/fsnotify v1.4.7 /go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo =
You can’t perform that action at this time.
0 commit comments