Let say that I have
connection := pool.GetConnection().(*DummyConnection)
where pool.GetConnection
returns interface{}
and I would like to cast it to DummyConnection
.
I would like to change the GetConnection interface to return error. The code starts looking like this:
connectionInterface, err := pool.GetConnection()
connection := connectionInterface.(*DummyConnection)
I am wondering, can I avoid the need of helper variable and have these on a single line?