ARTS-S golang goroutines and channels

Posted zhouyang209117

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ARTS-S golang goroutines and channels相关的知识,希望对你有一定的参考价值。

向tcp服务端发消息

package main

import (
    "io"
    "log"
    "net"
    "os"
)

func main() 
    conn, err := net.Dial("tcp", "localhost:8080")
    defer conn.Close()
    if err != nil 
        log.Fatal(err)
    
    go mustCopy(os.Stdout, conn)
    mustCopy(conn, os.Stdin)


func mustCopy(dst io.Writer, src io.Reader)  
    if _, err := io.Copy(dst, src); err != nil 
        log.Printf("mustCopy error:%v", err)
    

以上是关于ARTS-S golang goroutines and channels的主要内容,如果未能解决你的问题,请参考以下文章

ARTS-S golang单元测试

Golang之goroutine

golang goroutine例子[golang并发代码片段]

golang Golangでgoroutine

golang的goroutine与channel

golang Context for goroutines