@@ -55,6 +55,13 @@ func Format(template string, args ...any) string {
5555 continue
5656 }
5757 // find end of placeholder
58+ // process empty pair - {}
59+ if template [i + 1 ] == '}' {
60+ i ++
61+ formattedStr .WriteString ("{}" )
62+ continue
63+ }
64+ // process non-empty placeholder
5865 j = i + 2
5966 for {
6067 if j >= templateLen {
@@ -117,14 +124,9 @@ func Format(template string, args ...any) string {
117124 strVal := getItemAsStr (& args [argNumber ], & argFormatOptions )
118125 formattedStr .WriteString (strVal )
119126 } else {
120- if argNumberStr != "" {
121- formattedStr .WriteByte ('{' )
122- formattedStr .WriteString (argNumberStr )
123- formattedStr .WriteByte ('}' )
124- } else {
125- // complicated case when we have brackets in line and open line at the end
126- formattedStr .WriteByte ('{' )
127- }
127+ formattedStr .WriteByte ('{' )
128+ formattedStr .WriteString (argNumberStr )
129+ formattedStr .WriteByte ('}' )
128130 }
129131 i = j
130132 }
@@ -170,10 +172,18 @@ func FormatComplex(template string, args map[string]any) string {
170172 break
171173 }
172174
173- if template [i + 1 ] == '{' { // todo: umv: this not considering {{0}}
175+ if template [i + 1 ] == '{' {
174176 formattedStr .WriteByte ('{' )
175177 continue
176178 }
179+ // find end of placeholder
180+ // process empty pair - {}
181+ if template [i + 1 ] == '}' {
182+ i ++
183+ formattedStr .WriteString ("{}" )
184+ continue
185+ }
186+ // process non-empty placeholder
177187
178188 // find end of placeholder
179189 j = i + 2
@@ -215,14 +225,12 @@ func FormatComplex(template string, args map[string]any) string {
215225 strVal := getItemAsStr (& arg , & argFormatOptions )
216226 formattedStr .WriteString (strVal )
217227 } else {
218- if argNumberStr != "" {
219- formattedStr .WriteByte ('{' )
220- formattedStr .WriteString (argNumberStr )
221- formattedStr .WriteByte ('}' )
222- } else {
223- // complicated case when we have brackets in line and open line at the end
224- formattedStr .WriteByte ('{' )
225- }
228+ formattedStr .WriteByte ('{' )
229+
230+ //if argNumberStr != "" {
231+ formattedStr .WriteString (argNumberStr )
232+ formattedStr .WriteByte ('}' )
233+ //}
226234 }
227235 i = j
228236 }
0 commit comments