GoStore is a lightweight key/value database written in Go.
I chose to build GoStore to learn how databases like Redis and Sqlite work internally.
- B+Tree index with splitting, merging, borrowing and rebalancing
- Pager for fixed-size page IO + free-list management
- Write-Ahead Log for crash recovery
- Authenticated TCP server with a simple text protocol
- Optional TLS encryption for secure communication
- Admin CLI for creating / deleting databases and managing users
git clone https://github.com/taran1sdev/GoStore.git
cd gostore
go build ./cmd/gostoreApplication data is stored in ~/.local/share/gostore by default
├── cert
│ ├── server.crt
│ └── server.key
├── config.yaml
├── data
│ └── test
│ └── test.db
├── log
└── users.json
The CLI was built with cobra and provides an administrative interface
GoStore CLI
Usage:
gostore [command]
Available Commands:
create Create a new database
create-user Create a new GoStore user
delete Delete an existing database
delete-user Delete a GoStore user
grant Grant user access to db
help Help about any command
revoke Revoke user access to a database
start Start GoStore server
Flags:
--config string Path to config.yaml
-h, --help help for gostore
--home string GoStore home directory
Use "gostore [command] --help" for more information about a command.
Users must be granted access to databases through the CLI
- User - Read/Write
- Guest - Read Only
By default the server will start on localhost:57083 - you can change this in config.yaml
To start the server with default settings run
gostore startTo connect via nc
nc localhost 57083To start the server using TLS encryption first enable TLS in config.yaml then generate a TLS key/certificate
openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.crt -days 365 -nodes -subj "/CN=dev"By default the application will look in gostore/certs for the the key/certificate files, this can be changed in config.yaml
Use openssl to connect to the server
openssl s_client -connect 127.0.0.1:57083 -servername localhostClients communicate with simple text commands:
AUTH username password
OPEN dbname
SET key value
GET key
DEL key
QUIT
- Go client library for embedding GoStore directly in Go projects
- Binary protocol for faster clients
- Compression for large database files
- Snapshots / backups
- Support for Windows