func (b *Buffer) WriteRune(r rune) (n int, err error) {
	tmp := bytes.Buffer{}
	n, err = tmp.WriteRune(r)
	if err != nil {
		return n, err
	}
	return b.Write(tmp.Bytes())
}
WriteRune writes a rune.

It uses bytes.Buffer and Buffer.Write underhood.
package buffer
import (
	"bytes"
	"crypto/rand"
	"io"
	"io/ioutil"
	"os"
	"path/filepath"
	"unicode/utf8"
	"github.com/minio/sio"
	"github.com/pkg/errors"
)
const (
	DefaultMaxMemorySize = 2 << 20  
)
var (
	ErrBufferFinished = errors.New("buffer is finished")
)
type Buffer struct {
	maxInMemorySize int
	writingFinished bool
	readingFinished bool
	size   int
	offset int
	tempFileDir string
	encrypt       bool
	encryptionKey [32]byte
	buff bytes.Buffer
	writeFile io.WriteCloser
	readFile io.ReadCloser
	useFile  bool
	filename string
}
func NewBufferWithMaxMemorySize(maxInMemorySize int) *Buffer {
	b := &Buffer{
		maxInMemorySize: maxInMemorySize,
	}
	b.buff.Grow(maxInMemorySize / 2)
	return b
}
func NewBuffer(buf []byte) *Buffer {
	b := NewBufferWithMaxMemorySize(DefaultMaxMemorySize)
	if buf == nil || len(buf) == 0 {
		return b
	}
	_, err := b.Write(buf)
	if err != nil {
		panic(err)
	}
	return b
}
func NewBufferString(s string) *Buffer {
	return NewBuffer([]byte(s))
}
func (b *Buffer) ChangeTempDir(dir string) error {
	f, err := os.Open(dir)
	if err != nil {
		return errors.Wrapf(err, "can't open directory '%s'", dir)
	}
	defer f.Close()
	stats, err := f.Stat()
	if err != nil {
		return errors.Wrapf(err, "can't get stats of the directory '%s'", dir)
	}
	if !stats.IsDir() {
		return errors.Errorf("'%s' is not a directory", dir)
	}
	path, err := filepath.Abs(dir)
	if err != nil {
		return errors.New("can't get an absolute path")
	}
	b.tempFileDir = path
	return nil
}
func (b *Buffer) EnableEncryption() error {
	b.encrypt = true
	key := make([]byte, len(b.encryptionKey))
	_, err := rand.Read(key)
	if err != nil {
		return errors.Wrap(err, "can't read random data")
	}
	for i := range key {
		b.encryptionKey[i] = key[i]
	}
	return nil
}
func (b *Buffer) Write(data []byte) (n int, err error) {
	if b.writingFinished {
		return 0, ErrBufferFinished
	}
	defer func() {
		b.size += n
	}()
	if !b.useFile {
		if b.buff.Len()+len(data) <= b.maxInMemorySize {
			n, err = b.buff.Write(data)
			return
		}
		bound := b.maxInMemorySize - b.buff.Len()
		n, err = b.buff.Write(data[:bound])
		if err != nil {
			return
		}
		data = data[bound:]
		b.useFile = true
		file, err := ioutil.TempFile(b.tempFileDir, "go-disk-buffer-*.tmp")
		if err != nil {
			return n, errors.Wrap(err, "can't create a temp file")
		}
		var writeFile io.WriteCloser = file
		if b.encrypt {
			writeFile, err = sio.EncryptWriter(file, sio.Config{Key: b.encryptionKey[:]})
			if err != nil {
				return n, errors.Wrap(err, "can't create an encryption stream")
			}
		}
		b.writeFile = writeFile
		b.filename = file.Name()
	}
	n1, err := b.writeFile.Write(data)
	n += n1
	return
}
func (b *Buffer) WriteByte(c byte) error {
	slice := []byte{c}
	_, err := b.Write(slice)
	return err
}