edsrzf / mmap-go

A portable mmap package for Go
BSD 3-Clause "New" or "Revised" License
938 stars 129 forks source link

Don't call flush if the file was opened as rdonly #18

Closed bheni closed 5 years ago

bheni commented 5 years ago

Currently the tests don't even pass for windows. Failure output:

--- FAIL: TestUnmap (0.00s)
    mmap_test.go:43: error unmapping: FlushFileBuffers: Access is denied.
--- FAIL: TestNonZeroOffset (0.00s)
    mmap_test.go:143: FlushFileBuffers: Access is denied.
FAIL
FAIL    github.com/edsrzf/mmap-go       0.185s

This change simply skips flushing if the file was opened as rdonly

edsrzf commented 5 years ago

Thank you, but I went ahead and merged #17 which fixes this and also adds Travis CI so things shouldn't break again in such an obvious way.

bheni commented 5 years ago

Awesome. I'm just happy to have it fixed... Though I don't understand why you would want to allow windows.FlushViewOfFile to be called if it's not writable. I would think the entirety of the flush function should be skipped.