避免在类型开关的分支中使用类型断言

I use type switches in Go, e.g. the following one:

switch question.(type) {
case interfaces.ComputedQuestion:
    handleComputedQuestion(question.(interfaces.ComputedQuestion), symbols)
case interfaces.InputQuestion:
    handleInputQuestion(question.(interfaces.InputQuestion), symbols)
}

Is there a way to prevent that I have to assert the type of question inside the case before I can pass it to another function?

Yes, assigning the result of the type switch will give you the asserted type

switch question := question.(type) {
case interfaces.ComputedQuestion:
    handleComputedQuestion(question, symbols)
case interfaces.InputQuestion:
    handleInputQuestion(question, symbols)
}

http://play.golang.org/p/qy0TPhypvp