/safebuffer

A simple Go library to get a race-condition free mock of os.Stdin or Stdout

Primary LanguageGoMIT LicenseMIT

Safe Buffer Build Status

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)