Skip to content

Commit

Permalink
fix: correct do script error check (#563)
Browse files Browse the repository at this point in the history
Correct the error check in the Do method so it's more idiomatic.
  • Loading branch information
wenpeng committed Jul 1, 2022
1 parent 2c2a5c2 commit d3b4cc3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion redis/script.go
Expand Up @@ -79,7 +79,7 @@ func (s *Script) DoContext(ctx context.Context, c Conn, keysAndArgs ...interface
// causing the script to load).
func (s *Script) Do(c Conn, keysAndArgs ...interface{}) (interface{}, error) {
v, err := c.Do("EVALSHA", s.args(s.hash, keysAndArgs)...)
if e, ok := err.(Error); ok && strings.HasPrefix(string(e), "NOSCRIPT ") {
if err != nil && strings.HasPrefix(err.Error(), "NOSCRIPT ") {
v, err = c.Do("EVAL", s.args(s.src, keysAndArgs)...)
}
return v, err
Expand Down

0 comments on commit d3b4cc3

Please sign in to comment.