type person struct{
Name string
Age int
}
// parameters : (pointer to person struct), which is basically address of person object
func printPerson(p *person) {
// when we add '*' to a address, then it becomes dereferencing, Hence
// I read "*p.Name" as "person object dot Name" and i expect it to give value,
// I get this error:
// ./prog.go:20:15: invalid indirect of p.Name (type string)
// ./prog.go:20:24: invalid indirect of p.Age (type int)
fmt.Println(*p.Name, *p.Age) // does …Run Code Online (Sandbox Code Playgroud) Out of 3 code snippets, the one with channels declared in local scope works, other code snippets gives deadlock issue, One of the previously answered SO question here says try to avoid declaring channel in the global scope. I checked in the official docs, but I didn't find any explanation.
Why is the global scope channel giving an error although I am not blocking the channel from sending and receiving? why am I getting a deadlock issue here?
How …