I was wondering if doing something like this in golang is even possible --
type MyStruct struct {
id int
}
func (ms *MyStruct) PrintHello() {
fmt.Printf("Hello from original method %v", ms.id)
}
func main() {
fmt.Println("Hello, playground")
m := MyStruct{}
m.PrintHello()
m.PrintHello = func() {fmt.Printf("Hello from newer method 2")}
}
Error: cannot assign to m.PrintHello
https://play.golang.org/p/2oJQFFH4O5
Sorry if this doesn't make sense for Go programmers, I am new to Go and wondering if some of the things that can be done in dynamically typed languages can be done in Go. Thanks! :-)