...

Source file src/github.com/go-redis/redis/internal/util.go

Documentation: github.com/go-redis/redis/internal

     1  package internal
     2  
     3  import "github.com/go-redis/redis/internal/util"
     4  
     5  func ToLower(s string) string {
     6  	if isLower(s) {
     7  		return s
     8  	}
     9  
    10  	b := make([]byte, len(s))
    11  	for i := range b {
    12  		c := s[i]
    13  		if c >= 'A' && c <= 'Z' {
    14  			c += 'a' - 'A'
    15  		}
    16  		b[i] = c
    17  	}
    18  	return util.BytesToString(b)
    19  }
    20  
    21  func isLower(s string) bool {
    22  	for i := 0; i < len(s); i++ {
    23  		c := s[i]
    24  		if c >= 'A' && c <= 'Z' {
    25  			return false
    26  		}
    27  	}
    28  	return true
    29  }
    30  
    31  func Unwrap(err error) error {
    32  	u, ok := err.(interface {
    33  		Unwrap() error
    34  	})
    35  	if !ok {
    36  		return nil
    37  	}
    38  	return u.Unwrap()
    39  }
    40  

View as plain text