Support of named parameters pgx in Goland
Goland doesn't recognize named paramters.
It highlights them as errors in the query and shows the message: “Unable to resolve column ‘delete_date’.”
Example Code:
func deleteOldEntities(deleteDate time.Time) error {
query := `
DELETE FROM table
WHERE last_seen < @delete_date;
`
bindVars := pgx.NamedArgs{
"delete_date": deleteDate,
}
// ...
return nil
}
Is their a way to fix this?
请先登录再写评论。
Could you please share which import you are using for pgx.NamedArgs?
"github.com/jackc/pgx/v5"
Could you tell me what GoLand version you're running?
If it's not the latest version (2025.3.1.1 at the moment), could you try updating and see if the issue still happens?
Yes, its the same in the latest version.
Screenshot of the function:
Postgresql:
Good day,
DataGrip Team is here.
We tested the function you provided, excluding the package(assuming it doesn't play a role), and we don't see any issues with resolving objects of this table
The first thing to check is to ensure you have attached your data source and connected to your schema in that project file
If you have connected to your schema, which contains this table, and you're still experiencing this issue, please give us an update
Hello,
i have already attached the data source and choose the postgres public schema with the table “table”.
The columns are detected and auto-corrected, but the issue with the named argument remains unchanged.
Thanks for the update.
Yes, I am seeing that in my GoLand instance too. The problem is that this parametrized variable used in the query filter is not a plain PostgreSQL dialect. As a result, the injection is trying to make a guess, what the @ literal consists of. In this case, you need to add your own user parameters to recognize any external syntax. To do this, navigate to File | Settings | Tools | Database | Query Execution | User Parameters, and add @\w+ regex, preferably for all languages, and revisit your code afterward. The highlighting / resolve should be working fine then
Thank you very much, that solved my problem.