Home > Article > Backend Development > Is bytes.Buffer thread-safe in Go?
Go bytes.Buffer Thread Safety
In the Go programming language, the bytes.Buffer type implements a dynamically growing buffer of bytes. The documentation for bytes.Buffer does not explicitly mention thread safety. Is it thread-safe?
Answer
bytes.Buffer is not thread-safe.
The Go documentation adheres to the principle that if thread safety is not explicitly stated, it is not safe for concurrent access. Therefore, bytes.Buffer cannot be safely accessed by multiple goroutines simultaneously.
The above is the detailed content of Is bytes.Buffer thread-safe in Go?. For more information, please follow other related articles on the PHP Chinese website!