go 函数引用error
作者:互联网
package main
import (
"fmt"
)
type G struct {
Str string
Int int
}
func (g G) Getstr() (string,error) {
//var err error
if g.Str == ""{
fmt.Println("is a errors")
}
return g.Str,nil
}
x:=&G{"",19}
sss,err:=x.Getstr()
if err != nil{
fmt.Println(err) //is a errors
}
fmt.Println(sss)
标签:err,fmt,Getstr,Println,引用,Str,error,go 来源: https://www.cnblogs.com/cheyunhua/p/15706653.html