package commands import ( "errors" "redisClone/pkg/core" "strconv" ) func Decr(args []string, getShard func(k string) *core.Shard) interface{}{ key := args[1] shard := getShard(key) item, exists := shard.Data[key] if exists { strValue, ok := item.Value.(string) if !ok { err := errors.New("value is not an integer or out of range") return err } currentInt, err := strconv.Atoi(strValue) if err != nil { err := errors.New("value is not an integer or out of range") return err } newValueStr := strconv.Itoa(currentInt - 1) shard.Data[key] = core.Item{Value: newValueStr} return currentInt - 1 } else { shard.Data[key] = core.Item{Value: "-1"} return -1 } }