I'm trying to delete a database using the postgres driver (lib/pq) by doing a:
db.Exec("DROP DATABASE dbName;")
But I'd like to do a different conditional based on whether the error received is something strange, or is a "database does not exist" error.
My question is, is there a constant variable or something I can use to check if the error returned is a "database does not exist" error message, or would I have to manually parse the error string myself?
I tried to look in the documentation, but could not find anything for "database does not exist". I did however find this list: https://www.postgresql.org/docs/9.3/static/errcodes-appendix.html
Perhaps it fits under some other error code? Also I'm not quite sure the semantically correct way of fetching and comparing the error codes through the Postgres driver. I presume I should do something like this?:
if err.ErrorCode != "xxx"
Thank you.