package sql import "strings" // key,value To like sql func Like(key, val string) string { if val == "" { return "" } key = strings.TrimSpace(key) val = strings.TrimSpace(val) return key + " LIKE '%" + val + "%'" } // map strings to like sqls func Likes(in map[string]string) string { var ar []string for key, val := range in { sql := Like(key, val) if sql != "" { ar = append(ar, sql) } } if len(ar) == 0 { return "" } return strings.Join(ar, " AND ") }