Is the Go bytes.Buffer thread-safe?

前端 未结 4 2155
小蘑菇
小蘑菇 2021-02-19 05:22

In the Go programming language, is bytes.Buffer thread-safe? AFAIK, its documentation does not mention thread safety.

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-19 05:38

    Unfortunatelly I didn't know about https://golang.org/pkg/io/#Pipe, so implemented this thing myself. Here it is: https://github.com/latitov/milkthisbuffer

    I understand that it is useless when there's standard io.Pipe thing, but just in case anyone is interested in how you may reinvent the bicycle, only to discover few hours later that you just did exactly that - invented the bicycle ))

    Besides, it's mutex/locks free.

提交回复
热议问题