goyave.dev/goyave/v4@v4.4.11/util/sqlutil/sqlutil.go (about) 1 package sqlutil 2 3 import "strings" 4 5 // EscapeLike escape "%" and "_" characters in the given string 6 // for use in SQL "LIKE" clauses. 7 func EscapeLike(str string) string { 8 escapeChars := []string{"%", "_"} 9 for _, v := range escapeChars { 10 str = strings.ReplaceAll(str, v, "\\"+v) 11 } 12 return str 13 }