| 178 | } |
| 179 | |
| 180 | func parseParamSquareBrackets(k string) (string, error) { |
| 181 | bb := bytebufferpool.Get() |
| 182 | defer bytebufferpool.Put(bb) |
| 183 | |
| 184 | kbytes := []byte(k) |
| 185 | openBracketsCount := 0 |
| 186 | |
| 187 | for i, b := range kbytes { |
| 188 | if b == '[' { |
| 189 | openBracketsCount++ |
| 190 | if i+1 < len(kbytes) && kbytes[i+1] != ']' { |
| 191 | if err := bb.WriteByte('.'); err != nil { |
| 192 | return "", err //nolint:wrapcheck // unnecessary to wrap it |
| 193 | } |
| 194 | } |
| 195 | continue |
| 196 | } |
| 197 | |
| 198 | if b == ']' { |
| 199 | openBracketsCount-- |
| 200 | if openBracketsCount < 0 { |
| 201 | return "", ErrUnmatchedBrackets |
| 202 | } |
| 203 | continue |
| 204 | } |
| 205 | |
| 206 | if err := bb.WriteByte(b); err != nil { |
| 207 | return "", err //nolint:wrapcheck // unnecessary to wrap it |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | if openBracketsCount > 0 { |
| 212 | return "", ErrUnmatchedBrackets |
| 213 | } |
| 214 | |
| 215 | return bb.String(), nil |
| 216 | } |
| 217 | |
| 218 | func isStringKeyMap(t reflect.Type) bool { |
| 219 | return t.Kind() == reflect.Map && t.Key().Kind() == reflect.String |