From 7ca46642b540174dae8a92b91e967809697a13c4 Mon Sep 17 00:00:00 2001 From: hdt3213 Date: Mon, 28 Mar 2022 21:09:46 +0800 Subject: [PATCH] update help --- .gitignore | 1 + build.sh | 4 ++++ cmd.go | 7 ++++--- core/zset.go | 3 +++ 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 build.sh diff --git a/.gitignore b/.gitignore index 474488e..0deef49 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ # Dependency directories (remove the comment below to include it) # vendor/ .idea +target \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..0306e1f --- /dev/null +++ b/build.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o target/rdb-linux-amd64 ./ +go build -o target/rdb-darwin ./ \ No newline at end of file diff --git a/cmd.go b/cmd.go index 8003e65..ce0b75a 100644 --- a/cmd.go +++ b/cmd.go @@ -13,12 +13,13 @@ This is a tool to parse Redis' RDB files Options: -c command, including: json/memory/aof -o output file path - -n number of result + -n number of result, using in -port listen port for flame graph web service -sep separator for flamegraph, rdb will separate key by it, default value is ":". supporting multi separators: -sep sep1 -sep sep2 Examples: +parameters between '[' and ']' is optional 1. convert rdb to json rdb -c json -o dump.json dump.rdb 2. generate memory report @@ -26,9 +27,9 @@ Examples: 3. convert to aof file rdb -c aof -o dump.aof dump.rdb 4. get largest keys - rdb -c bigkey -o dump.aof dump.rdb + rdb -c bigkey [-o dump.aof] [-n 10] dump.rdb 5. draw flamegraph - rdb -c flamegraph -port 16379 -sep : dump.rdb + rdb -c flamegraph [-port 16379] [-sep :] dump.rdb ` type separators []string diff --git a/core/zset.go b/core/zset.go index f299f9f..8bbdc8e 100644 --- a/core/zset.go +++ b/core/zset.go @@ -22,6 +22,9 @@ func (dec *Decoder) readZSet(zset2 bool) ([]*model.ZSetEntry, error) { } else { score, err = dec.readLiteralFloat() } + if err != nil { + return nil, err + } entries = append(entries, &model.ZSetEntry{ Member: string(member), Score: score,