本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
427B

  1. package internal
  2. import "github.com/go-redis/redis/internal/util"
  3. func ToLower(s string) string {
  4. if isLower(s) {
  5. return s
  6. }
  7. b := make([]byte, len(s))
  8. for i := range b {
  9. c := s[i]
  10. if c >= 'A' && c <= 'Z' {
  11. c += 'a' - 'A'
  12. }
  13. b[i] = c
  14. }
  15. return util.BytesToString(b)
  16. }
  17. func isLower(s string) bool {
  18. for i := 0; i < len(s); i++ {
  19. c := s[i]
  20. if c >= 'A' && c <= 'Z' {
  21. return false
  22. }
  23. }
  24. return true
  25. }
上海开阖软件有限公司 沪ICP备12045867号-1