https://github.com/opencoff/go-mmap
OS Independent mmap abstraction
https://github.com/opencoff/go-mmap
Last synced: about 1 year ago
JSON representation
OS Independent mmap abstraction
- Host: GitHub
- URL: https://github.com/opencoff/go-mmap
- Owner: opencoff
- License: gpl-2.0
- Created: 2024-01-07T19:25:30.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-01T03:02:54.000Z (over 1 year ago)
- Last Synced: 2025-04-01T04:21:49.329Z (over 1 year ago)
- Language: Go
- Size: 25.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# What is this
This is an OS independent `mmap(2)` abstractions.
# How can I use it?
Here is an example program:
```go
// error checking omitted
fd, _ := os.Open(filename)
map := mmap.New(fd)
// map the whole file as a RO mapping for sequential I/O
p, err := map.Map(0, 0, mmap.PROT_READ, mmap.F_READAHEAD)
if err != nil {
...
}
// p now represents the mapping of the entire file
// buf represents the file contents as a byte slice
buf := p.Bytes()
...
p.Unmap()
fd.Close()
```