Closed kingbhanu closed 4 years ago
Also should I return any error if connection is found nil or just return error as nil?
Hmm. Hard to say. I'm not sure if anything depends on that, so probably run the checks before you push an error if the conn is nil. Otherwise, I see no issue with it.
Calling close on a nil connection seems like it should throw an error back but it doesn't look like it is coded that way today. Go won't panic on a function call of a nil struct pointer so it'd be up to the programmer to handle these situations as desired.
Though, I'm not sure what a caller would expect trying to call close on a nil connection object. Technically, it's closed if its nil, returning the error would more or less inform the caller the Conn
is nil.
Think I'd be ok with keeping it the way it is currently.
Yes, the connections ideally should not be closed in case of error. I am updating the PR.