package main import( "fmt" "os" "bufio" ) func main(){ in :=make(chan string) out :=make(chan string) reader := bufio.NewReader(os.Stdin) go func(){ for { a:= <-in out <- a fmt.Println("in",a) } }() go func(){ for { b:=<-out fmt.Println("out",b) } }() for{ line, _:= reader.ReadString('\n') fmt.Println("<----------------------------->") in <- line } }
有疑问加站长微信联系(非本文作者)