I have this code segement
query := `
SELECT
co_username as username,
co_password as password
FROM
servers.co
WHERE
co_url = concat('https://', :co_url)
`
args := map[string]interface{}{
"co_url": in.Url,
}
rows, err := collectorsConfig.Db.NamedQueryContext(ctx, query, args)
if err != nil {
msg := "Error getting co credentials for co '%s': %v"
log.Error.Printf(msg, in.Url, err)
return
}
When runnig this snippet, I get an error like this:
Error getting co credentials for co 'some.random.fqdn': could not find name in map[string]interface {}{"co_url":"some.random.fqdn"}
But if I rework the snippet to be
in.Url = "https://" + in.Url
query := `
SELECT
co_username as username,
co_password as password
FROM
servers.co
WHERE
co_url = :co_url
`
Everything works. Is there a reason the named input is not working with the Concat
function?