File tree Expand file tree Collapse file tree 2 files changed +17
-16
lines changed Expand file tree Collapse file tree 2 files changed +17
-16
lines changed Original file line number Diff line number Diff line change 11package caps_test
22
33import (
4+ "fmt"
45 "testing"
56
67 "github.com/chanced/caps"
@@ -106,3 +107,19 @@ func TestConverterTableOps(t *testing.T) {
106107 // t.Errorf("expected \"WSS\", got \"%s\"", wss.Screaming)
107108 // }
108109}
110+
111+ type MyConverter struct {}
112+
113+ func (MyConverter ) Convert (req caps.ConvertRequest ) string {
114+ res := caps .DefaultConverter .Convert (req )
115+ if req .Style == caps .StyleLowerCamel && req .ReplaceStyle == caps .ReplaceStyleCamel && res == "id" {
116+ return "_id"
117+ }
118+ return res
119+ }
120+
121+ func ExampleWithConverter () {
122+ fmt .Println (caps .ToLowerCamel ("id" , caps .WithConverter (MyConverter {}), caps .WithReplaceStyle (caps .ReplaceStyleCamel )))
123+ // Output:
124+ // _id
125+ }
Original file line number Diff line number Diff line change @@ -78,19 +78,3 @@ func ExampleToTitle() {
7878 // Output:
7979 // This Is An Example ID 32
8080}
81-
82- type MyConverter struct {}
83-
84- func (MyConverter ) Convert (req caps.ConvertRequest ) string {
85- res := caps .DefaultConverter .Convert (req )
86- if req .Style == caps .StyleLowerCamel && req .ReplaceStyle == caps .ReplaceStyleCamel && res == "id" {
87- return "_id"
88- }
89- return res
90- }
91-
92- func ExampleWithConverter () {
93- fmt .Println (caps .ToLowerCamel ("id" , caps .WithConverter (MyConverter {}), caps .WithReplaceStyle (caps .ReplaceStyleCamel )))
94- // Output:
95- // _id
96- }
You can’t perform that action at this time.
0 commit comments