假设我有
connection := pool.GetConnection().(*DummyConnection)
在哪里pool.GetConnection返回interface{},我想将它转换为DummyConnection.
我想更改 GetConnection 接口以返回错误。代码开始看起来像这样:
connectionInterface, err := pool.GetConnection()
connection := connectionInterface.(*DummyConnection)
我想知道,我可以避免使用辅助变量并将它们放在一行上吗?
MM们
开心每一天1111
相关分类