Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Mizu
Commits
70982c28
Unverified
Commit
70982c28
authored
3 years ago
by
M. Mert Yıldıran
Committed by
GitHub
3 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Fix the interface conversion errors in Redis (#334)
parent
61f24320
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tap/extensions/redis/read.go
+24
-6
tap/extensions/redis/read.go
with
24 additions
and
6 deletions
+24
-6
tap/extensions/redis/read.go
+
24
-
6
View file @
70982c28
...
...
@@ -296,12 +296,28 @@ func (p *RedisProtocol) Read() (packet *RedisPacket, err error) {
switch
x
.
(
type
)
{
case
[]
interface
{}
:
array
:=
x
.
([]
interface
{})
packet
.
Command
=
RedisCommand
(
strings
.
ToUpper
(
string
(
array
[
0
]
.
([]
uint8
))))
if
len
(
array
)
>
1
{
packet
.
Key
=
string
(
array
[
1
]
.
([]
uint8
))
}
if
len
(
array
)
>
2
{
packet
.
Value
=
string
(
array
[
2
]
.
([]
uint8
))
switch
array
[
0
]
.
(
type
)
{
case
[]
uint8
:
packet
.
Command
=
RedisCommand
(
strings
.
ToUpper
(
string
(
array
[
0
]
.
([]
uint8
))))
if
len
(
array
)
>
1
{
packet
.
Key
=
string
(
array
[
1
]
.
([]
uint8
))
}
if
len
(
array
)
>
2
{
packet
.
Value
=
string
(
array
[
2
]
.
([]
uint8
))
}
if
len
(
array
)
>
3
{
packet
.
Value
=
fmt
.
Sprintf
(
"[%s"
,
packet
.
Value
)
for
_
,
item
:=
range
array
[
3
:
]
{
packet
.
Value
=
fmt
.
Sprintf
(
"%s, %s"
,
packet
.
Value
,
item
.
([]
uint8
))
}
packet
.
Value
=
strings
.
TrimSuffix
(
packet
.
Value
,
", "
)
packet
.
Value
=
fmt
.
Sprintf
(
"%s]"
,
packet
.
Value
)
}
default
:
msg
:=
fmt
.
Sprintf
(
"Unrecognized element in Redis array: %v
\n
"
,
reflect
.
TypeOf
(
array
[
0
]))
log
.
Printf
(
msg
)
err
=
errors
.
New
(
msg
)
return
}
case
[]
uint8
:
val
:=
string
(
x
.
([]
uint8
))
...
...
@@ -316,6 +332,8 @@ func (p *RedisProtocol) Read() (packet *RedisPacket, err error) {
}
case
string
:
packet
.
Value
=
x
.
(
string
)
case
int64
:
packet
.
Value
=
fmt
.
Sprintf
(
"%d"
,
x
.
(
int64
))
default
:
msg
:=
fmt
.
Sprintf
(
"Unrecognized Redis data type: %v
\n
"
,
reflect
.
TypeOf
(
x
))
log
.
Printf
(
msg
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment