Safe Buffer
A very simple buffer adding a mutex between each read and write operation so they can be used without causing race conditions.
I am using this as a os.Stdin
mock in tests.
Usage
stdin := safebuffer.NewMock()
Then, use the mock as a normal ReadWriter.
stdin.Write([]byte("hello"))
ioutil.ReadAll(stdin)