redis / go-redis

Redis Go client
https://redis.uptrace.dev
BSD 2-Clause "Simplified" License
20.06k stars 2.37k forks source link

fix: add Cmder annotation #2816

Closed rfyiamcool closed 10 months ago

rfyiamcool commented 11 months ago

summary

Every time I call this methods, I need to test the output, I have added some samples of the output here. Next time I look at the code comments, I'll know how to use these methods. 😁

e.g. by printing the data, I knew the difference of the methods in Cmder.

...

func (redisHook) ProcessHook(hook redis.ProcessHook) redis.ProcessHook {
    return func(ctx context.Context, cmd redis.Cmder) error {
        fmt.Printf("starting processing: <%s>\n", cmd)
        err := hook(ctx, cmd)
        fmt.Printf("finished processing: <%s>\n", cmd)

        fmt.Printf("--- %+v \n", cmd.FullName())
        fmt.Printf("--- %+v \n", cmd.Args())
        fmt.Printf("--- %+v \n", cmd.Name())
        fmt.Printf("--- %+v \n", cmd.String())
        fmt.Printf("--- %+v \n", cmd.Err())

        return err
    }
}

...