why are all goroutines deadlocked?
I am new to Go and also looked abit on the thread "throw: all goroutines
are asleep", but I am still wondering why this piece of code deadlock. I
believe that I put a number in namesInDir, and should be able to print it
afterwards. It seems that I can not add the number to the channel - which
confuses me. Anyone that can help me?
type uniprot struct
{
namesInDir chan int
}
func main(){
u := uniprot{}
u.namesInDir = make(chan int)
u.namesInDir <- 1
//u.readFilenames(os.Args[1])
u.printName()
}
func (u* uniprot) printName(){
name := <-u.namesInDir
fmt.Println(name)
}
No comments:
Post a Comment