add sync to buffer.go