packagemainimport("fmt""time")typeObjstruct{valintnamestring}funcmain(){ch:=make(chanint,1)ok:=make(chan*Obj,2)gofunc(){deferclose(ok)deferclose(ch)ok<-&Obj{val:1,name:"ww"}ch<-1}()gotest(ch,ok)select{case<-time.After(2*time.Second):fmt.Println("2s close main")}}functest(chchanint,okchan*Obj){i:=0for{o:=<-okfmt.Println(o)r:=<-chfmt.Println(r)i++ifi>=2{break}}}