A buffer pool file I/O library for Go

bfile

GoDoc

A buffer pool file I/O library for Go.

The purpose of the library is to provide I/O mechanisms for copying data to and from a buffer in user space and maintain complete control over how and when it transfers pages.

This is an alternative to using mmap on large DBMS like files.

Install

go get github.com/tidwall/bfile

Usage

Has the normal file opening functions:

func Create(name string) (*File, error)
func Open(name string) (*File, error)
func OpenFile(name string, flat int, perm fs.FileMode) (*File, error)

The resulting file works a lot like a standard os.File, but with an automatically maintained pool of buffered pages. The default size of all buffered pages will not exceed 8 MB.

For custom size buffers use the OpenFileSize.

All operations are thread-safe.

Other important functions:

func (*File) WriteAt([]byte, int64) (int, error) // random writes
func (*File) ReadAt([]byte, int64) (int, error)  // random reads
func (*File) Read([]byte) (int, error)           // sequential reads
func (*File) Write([]byte) (int, error)          // sequential writes
func (*File) Flush() error                       // flush buffer data
func (*File) Sync() error                        // flush and sync data to stable storage
func (*File) Close() error                       // close the file
func (*File) Clone() error                       // create a shallow copy
func (*File) Truncate(int64) error               // resize the file
func (*File) Stat() os.FileInfo                  // file size and other info

The Clone function will create a shallow copy of File, which shares the same in memory pages as all other clones.

The Close function will always flush and sync your data prior to returning.

Contact

Josh Baker @tidwall

License

Source code is available under the MIT License.

Similar Resources

Goful is a CUI file manager written in Go.

Goful is a CUI file manager written in Go.

Goful Goful is a CUI file manager written in Go. Works on cross-platform such as gnome-terminal and cmd.exe. Displays multiple windows and workspaces.

Dec 28, 2022

Read a tar file contents using go1.16 io/fs abstraction

Read a tar file contents using go1.16 io/fs abstraction

go-tarfs Read a tar file contents using go1.16 io/fs abstraction Usage ⚠ī¸ go-tarfs needs go=1.16 Install: go get github.com/nlepage/go-tarfs Use: pac

Dec 1, 2022

Open Source Continuous File Synchronization

Open Source Continuous File Synchronization

Goals Syncthing is a continuous file synchronization program. It synchronizes files between two or more computers. We strive to fulfill the goals belo

Jan 9, 2023

Cross-platform file system notifications for Go.

File system notifications for Go fsnotify utilizes golang.org/x/sys rather than syscall from the standard library. Ensure you have the latest version

Jan 1, 2023

The best HTTP Static File Server, write with golang+vue

The best HTTP Static File Server, write with golang+vue

gohttpserver Goal: Make the best HTTP File Server. Features: Human-friendly UI, file uploading support, direct QR-code generation for Apple & Android

Dec 30, 2022

Dragonfly is an intelligent P2P based image and file distribution system.

Dragonfly is an intelligent P2P based image and file distribution system.

Dragonfly Note: The master branch may be in an unstable or even broken state during development. Please use releases instead of the master branch in o

Jan 9, 2023

Fast, dependency-free, small Go package to infer the binary file type based on the magic numbers signature

filetype Small and dependency free Go package to infer file and MIME type checking the magic numbers signature. For SVG file type checking, see go-is-

Jan 3, 2023

📂 Web File Browser

📂 Web File Browser

filebrowser provides a file managing interface within a specified directory and it can be used to upload, delete, preview, rename and edit your files.

Jan 9, 2023

Plik is a scalable & friendly temporary file upload system ( wetransfer like ) in golang.

Want to chat with us ? Telegram channel : https://t.me/plik_root_gg Plik Plik is a scalable & friendly temporary file upload system ( wetransfer like

Jan 2, 2023
Related tags
File system event notification library on steroids.

notify Filesystem event notification library on steroids. (under active development) Documentation godoc.org/github.com/rjeczalik/notify Installation

Dec 31, 2022
Go library for the TOML file format

Go-toml provides the following features for using data parsed from TOML documents

Dec 27, 2022
goelftools is library written in Go for parsing ELF file.

goelftools goelftools is library written in Go for parsing ELF file. This library is inspired by pyelftools and rbelftools. Motivation The motivation

Dec 5, 2022
Abstract File Storage

afs - abstract file storage Please refer to CHANGELOG.md if you encounter breaking changes. Motivation Introduction Usage Matchers Content modifiers S

Dec 30, 2022
a tool for handling file uploads simple

baraka a tool for handling file uploads for http servers makes it easier to make operations with files from the http request. Contents Install Simple

Nov 30, 2022
Bigfile -- a file transfer system that supports http, rpc and ftp protocol https://bigfile.site
Bigfile -- a file transfer system that supports http, rpc and ftp protocol   https://bigfile.site

Bigfile ———— a file transfer system that supports http, rpc and ftp protocol įŽ€äŊ“中文 ∙ English Bigfile is a file transfer system, supports http, ftp and

Dec 31, 2022
Read csv file from go using tags

go-csv-tag Read csv file from Go using tags The project is in maintenance mode. It is kept compatible with changes in the Go ecosystem but no new feat

Nov 16, 2022
Pluggable, extensible virtual file system for Go

vfs Package vfs provides a pluggable, extensible, and opinionated set of file system functionality for Go across a number of file system types such as

Jan 3, 2023
An epoll(7)-based file-descriptor multiplexer.

poller Package poller is a file-descriptor multiplexer. Download: go get github.com/npat-efault/poller Package poller is a file-descriptor multiplexer

Sep 25, 2022
QueryCSV enables you to load CSV files and manipulate them using SQL queries then after you finish you can export the new values to a CSV file
QueryCSV enables you to load CSV files and manipulate them using SQL queries then after you finish you can export the new values to a CSV file

QueryCSV enable you to load CSV files and manipulate them using SQL queries then after you finish you can export the new values to CSV file

Dec 22, 2021