package main

import "fmt"

func main() {
pings := make(chan string, 1)
pongs := make(chan string, 1)
ping(pings, "passwd message")
pong(pings, pongs)
fmt.Println(<-pongs)
} //只写chan pings
func ping(pings chan<- string, msg string) {
pings <- msg
} //只读chan pings
func pong(pings <-chan string, pongs chan<- string) {
msg := <-pings
pongs <- msg
}
04-28 13:21