Tag: 铸件

在Go中使用多个返回值的转换/types断言的习惯方式

在Go中input多个返回值的惯用方法是什么? 你可以在一行中完成,还是需要使用临时variables,例如我在下面的示例中完成的? package main import "fmt" func oneRet() interface{} { return "Hello" } func twoRet() (interface{}, error) { return "Hejsan", nil } func main() { // With one return value, you can simply do this str1 := oneRet().(string) fmt.Println("String 1: " + str1) // It is not as easy with two return values //str2, err […]