1、代码
1 package main 2 import ( 3 "fmt" 4 "strconv" 5 ) 6 7 func getValue(n int) (float32, string) { 8 var x float32 = float32(n) 9 var str string = strconv.Itoa(n) 10 return x, str 11 } 12 13 func main(){ 14 var n int = 10; 15 16 x, str := getValue(n) 17 18 fmt.Printf("x = %f\nstr = %s\n", x, str) 19 }
2、运行
$ go run multireturns.go x = 10.000000 str = 10
本文转自郝峰波博客园博客,原文链接:http://www.cnblogs.com/fengbohello/p/4620459.html,如需转载请自行联系原作者