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 } }
时间: 2024-11-10 14:54:06