go调用函数时,不能打印不带返回值的函数否则报used as value,不带返回值的函数直接函数即可
作者:互联网
package main
import "fmt"
var i int = 100
func TestInt() {
defer func() {
i+=100
}()
fmt.Println(i)
//return
}
func main() {
fmt.Println(TestInt())
//fmt.Println(i)
}
报错:.\test19.go:17:21: TestInt() used as value
标签:不带,func,函数,fmt,TestInt,used,go,Println,返回值 来源: https://www.cnblogs.com/cheyunhua/p/15755096.html