gogress is a lightweight Go-based file storage database with a simple write-ahead log (WAL) mechanism. It supports table creation, basic key-value operations, and crash recovery by replaying log files.
# Start the CLI
gogress-cli list-tables
cars
new_table
users
default
# create a table
gogress-cli create-table products
# create a record
gogress-cli put products sku123 hammer
# get a record
gogress-cli get products sku123
hammer
# run a simple SQL query (experimental)
gogress-cli sql "select * from products"
sku123: hammer-
Main Application
Root-level main.go launches the application. -
Command-Line Interface (CLI)
Theclidirectory contains CLI-specific code and tests (cli/main.go, cli/main_test.go). -
Database Implementation
The core database logic is implemented under the pkg/db folder:db.NewDB: Initializes a new database instance.db.Table: Provides methods likePutandGetto store and retrieve records.- Write-ahead logging and crash recovery is managed in
db.BuildIndex. - Experimental SQL entrypoint
db.SQLpowering thesqlCLI subcommand.
-
Tests
Unit tests cover various components:- Main application tests in main_test.go.
- Database tests in pkg/db/db_test.go and pkg/db/table_test.go.
- Go (version 1.16 or later)
- A Unix-like environment to support file system operations
Clone the repository and navigate to the project folder:
git clone https://github.com/igomez10/gogress.git
cd gogressBuild the project using go build:
go build -o gogress-cli cli/main.goRun all tests with:
go test ./...Or test specific packages:
go test ./pkg/dbThe database is initialized in db.NewDB and can be used to perform key-value operations. The CLI (located in the cli directory) currently supports commands such as listing tables (see TestListTables in cli/main_test.go).
Examples of operations include:
-
Put a Record:
Refer todb.Table.Putfor adding a new record. -
Get a Record:
Seedb.Table.Getfor retrieving stored values.
You can run a very small subset of SQL via the CLI or directly from Go. Currently supported:
- SELECT with a FROM clause:
select * from <table>- The query is tokenized by whitespace; the table name is read from the token after
from. - Returns up to 10 records by default; filters, ordering, projections, and joins are not supported yet.
- The query is tokenized by whitespace; the table name is read from the token after
CLI example:
gogress-cli sql "select * from products"Programmatic example:
records, err := db.SQL("select * from products")
if err != nil {
// handle error
}
for _, r := range records {
fmt.Printf("%s: %s\n", r.Key, r.Value)
}- Storage Files:
Data is stored in files under/tmp/gogress/(as set indb.initializeStorage). - Crash Recovery:
A write-ahead log (WAL) is maintained and used to rebuild the in-memory index viadb.BuildIndex.
- Tables
- Create:
gogress-cli create-table <name> - List:
gogress-cli list-tables - Delete:
gogress-cli delete-table <name>
- Create:
- Data
- Put:
gogress-cli put <table> <key> <value> - Get:
gogress-cli get <table> <key> - Scan:
gogress-cli scan <table> [--limit N] [--offset N] - SQL (experimental):
gogress-cli sql "select * from <table>"
- Put:
Feel free to fork the project and submit pull requests. For major changes, please open an issue first to discuss what you would like to change.
This project is provided without any warranty. See the LICENSE file