Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tidwall/mmap
Load file-backed memory
https://github.com/tidwall/mmap
Last synced: 3 months ago
JSON representation
Load file-backed memory
- Host: GitHub
- URL: https://github.com/tidwall/mmap
- Owner: tidwall
- Created: 2020-10-20T01:00:48.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-10-12T22:14:42.000Z (about 2 years ago)
- Last Synced: 2024-06-18T19:59:36.344Z (5 months ago)
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 120
- Watchers: 6
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mmap
Load file-backed memory.
Uses [edsrzf/mmap-go](https://github.com/edsrzf/mmap-go) under the hood.## Installing
```
go get -u github.com/tidwall/mmap
```## Using
Load a bigole file into a byte slice. This happens pretty much instantly even
if your file is many GBs.```go
data, err := mmap.Open("my-big-file.txt", false)
if err != nil {
panic(err)
}
```Now you can read the `data` slice like any other Go slice.
Make sure to release the data when your done.
```go
mmap.Close(data)
```Don't read the `data` after closing otherwise your f*cked.
That's all, bye now