Closed samriddhi closed 4 years ago
Try %q
instead of %s
.
@cbandy I tried that it gives the same error with the missing =.
Check the docs. In particular, you need to use single quotes around parameters with spaces. You could use QuoteLiteral for this, which would also handle the case where a parameter contains apostrophes or other special chars.
@peterstace I had to double escape singh\\ samriddhi
. Maybe there can be an exampke in the docs about this because I was just trying a single escape. I could not get the QuoteLiteral to work but since that is what the function would have done it's not a big deal
Thank you so much.
I am trying to connect to Postgres but my username has space in between my last and first name. Every time I hit a ping an error with the following error keeps popping up:
2019/12/05 15:05:29 missing "=" after "'samriddhi" in connection info string"
My code is the following:
const ( host = "localhost" port = 5432 user = "singh samriddhi" dbname = "db" )
psqlInfo := fmt.Sprintf("host=%s port=%d user=%s dbname=%s sslmode=disable", host, port, user, dbname)
How do I add space within my username? Or is there a workaround for this?