12 lines
314 B
Go
12 lines
314 B
Go
package shared
|
|
|
|
import "strings"
|
|
|
|
// LikePattern escapes SQL LIKE metacharacters and wraps term for a %term% match.
|
|
func LikePattern(term string) string {
|
|
term = strings.ReplaceAll(term, `\`, `\\`)
|
|
term = strings.ReplaceAll(term, `%`, `\%`)
|
|
term = strings.ReplaceAll(term, `_`, `\_`)
|
|
return "%" + term + "%"
|
|
}
|