I'm working with Go and PostgreSQL (pq driver), I have the following query
SELECT p.id, p.name, p.description, p.price, p.image, p.rate
FROM products AS p
WHERE LOWER(p.name) LIKE %$1% ORDER BY p.rate DESC
If I exec this query directly in PostgreSQL it work but in Golang says:
pq: syntax error at or near "%"
How can I fix it? I tried with "\%" but didn't works. thanks.
here is the complete source code
func FindByName(name *string) ([]*Product, error) {
    db, err := db.StablishConnection()
    if err != nil {
            log.Fatal(err)
            panic(err)
    }
    defer db.Close()
    query := `SELECT p.id, p.name, p.description, p.price, p.image, p.rate
        FROM products AS p
        WHERE LOWER(p.name) LIKE %$1% ORDER BY p.rate DESC`
    product_rows, err := db.Query(query, name)
    if err != nil {
            return nil, err
    }
    if product_rows == nil {
            return nil, errors.New("No Products Named " + *name)
    }
    products := []*Product{}
    for product_rows.Next() {
            product := new(Product)
            err = product_rows.Scan(&product.Id,
                    &product.Name,
                    &product.Description,
                    &product.Price,
                    &product.Image,
                    &product.Rate)
            if err != nil {
                    panic(err)
            }
            products = append(products, product)
    }
    return products, nil
}
 
     
     
     
     
     
     
    