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)





原文地址:https://www.cnblogs.com/cheyunhua/p/15706653.html