gstr_compare.go 682 B

123456789101112131415161718192021
  1. // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
  2. //
  3. // This Source Code Form is subject to the terms of the MIT License.
  4. // If a copy of the MIT was not distributed with this file,
  5. // You can obtain one at https://github.com/gogf/gf.
  6. package gstr
  7. import "strings"
  8. // Compare returns an integer comparing two strings lexicographically.
  9. // The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
  10. func Compare(a, b string) int {
  11. return strings.Compare(a, b)
  12. }
  13. // Equal reports whether `a` and `b`, interpreted as UTF-8 strings,
  14. // are equal under Unicode case-folding, case-insensitively.
  15. func Equal(a, b string) bool {
  16. return strings.EqualFold(a, b)
  17. }