go - Why net.Conn use ioutil.ReadAll can't read -


first use ioutil.readall(conn) can't read use io.copy can

tcpaddr, _ := net.resolvetcpaddr("tcp4", ":7777") conn, _ := net.dialtcp("tcp4", nil, tcpaddr)  scanner := bufio.newscanner(os.stdin) scanner.scan() {     data := scanner.bytes()     data = append(data, '\n')     conn.write(data)      go func(conn *net.tcpconn) {         io.copy(os.stdout, conn)         //res, _ := ioutil.readall(conn)         //fmt.println("server = ", string(res))     }(conn) } 


Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

java - How to implement an entity bound odata action in olingo v4.3 -