From fe721fe316484e815515ad9c22ab8f7de90e3951 Mon Sep 17 00:00:00 2001 From: vinllen Date: Wed, 24 Jul 2019 15:41:52 +0800 Subject: [PATCH] polish code --- src/redis-shake/main/main.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/redis-shake/main/main.go b/src/redis-shake/main/main.go index fe40357..b91c146 100644 --- a/src/redis-shake/main/main.go +++ b/src/redis-shake/main/main.go @@ -346,18 +346,17 @@ func sanitizeOptions(tp string) error { conf.Options.TargetDB = v } - if conf.Options.TargetDB > 0 && conf.Options.TargetType == conf.RedisTypeCluster { - return fmt.Errorf("target.db[%v] should in {-1, 0} when target type is cluster", conf.Options.TargetDB) - } - // if the target is "cluster", only allow pass db 0 if conf.Options.TargetType == conf.RedisTypeCluster { if conf.Options.TargetDB == -1 { conf.Options.FilterDBWhitelist = []string{"0"} // set whitelist = 0 conf.Options.FilterDBBlacklist = []string{} // reset blacklist log.Info("the target redis type is cluster, only pass db0") - } else { // targetDB == 0 + } else if conf.Options.TargetDB == 0 { log.Info("the target redis type is cluster, all db syncing to db0") + } else { + // > 0 + return fmt.Errorf("target.db[%v] should in {-1, 0} when target type is cluster", conf.Options.TargetDB) } }