Here is my code http://play.golang.org/p/h0N4t2ZAKQ
package main
import (
"fmt"
"reflect"
)
type Msg struct {
Message string
}
func print(y interface{}) {
z, ok := y.(Msg)
fmt.Println(reflect.TypeOf(z))
fmt.Println("Value of ok ", ok)
if ok {
fmt.Println("Message is "+ z.Message)
}
}
func main() {
foo := new(Msg)
foo.Message="Hello"
fmt.Println("Messege in main "+foo.Message)
print(foo)
}
When I run it z.Message does not print Hello Not sure why. Can someone clarify? Thanks in advance