I cannot call Print on a type before change string method that has a String method inside the type's String method:
type book struct{
id int
r relateF
//Or can be delare as r relateF
}
type relateF struct{
handle int
grade float64
name string
}
func(b book) String() string{
fmt.Println(b)//<=I want to print it before change String method
return fmt.Sprintf(b.r.name)
}
func main(){
b1:= book{456,relateF{5,48.2,"History of the world"}}
fmt.Println(b1)
}
it make a loop