I have been following lot of Tutorials on Closures
in golang
, but still couldn't really achieve the below one
I have a function named 'greeting' that takes the name
as the input and has a closure
within it, which would give the full-greeting message
func greeting(name string) func() string {
fullGreeting := ""
return func() string {
var message = "Welcome to Closures " + name
fullGreeting = message
return fullGreeting
}
}
func main() {
fmt.Println(greeting("Arun"))
}
Am expecting it to print Welcome to Closures Arun
while it is printing just the method-value 0x48b660