package main import ( "fmt" "log" ) func bb(s string)(string,error){ var x = func(str string)string{ s1 := "o" s2 := s1+str return s2 } if x(s) == "ok"{ return x(s), nil }else{ return "", fmt.Errorf("str error!!") } } func main() { rel,err := bb("k") if err != nil { log.Fatal(err) } fmt.Println(rel) }