From 1b1a3d5f79c0c22d79665f0dc966ac8b59600623 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 21 May 2023 13:17:18 -0700 Subject: [PATCH] Updated with gofmt --- drivers/bbolt/bbolt.go | 76 +++++++++++++++++----------------- drivers/cassandra/cassandra.go | 76 +++++++++++++++++----------------- drivers/hashmap/hashmap.go | 76 +++++++++++++++++----------------- drivers/nats/nats.go | 76 +++++++++++++++++----------------- drivers/redis/redis.go | 76 +++++++++++++++++----------------- hord.go | 60 +++++++++++++-------------- 6 files changed, 220 insertions(+), 220 deletions(-) diff --git a/drivers/bbolt/bbolt.go b/drivers/bbolt/bbolt.go index 23654bc..f071f24 100644 --- a/drivers/bbolt/bbolt.go +++ b/drivers/bbolt/bbolt.go @@ -3,56 +3,56 @@ Package bbolt provides a Hord database driver for BoltDB. BoltDB is an embedded key-value database that persists data on disk. To use this driver, import it as follows: - import ( - "github.com/madflojo/hord" - "github.com/madflojo/hord/bbolt" - ) + import ( + "github.com/madflojo/hord" + "github.com/madflojo/hord/bbolt" + ) -Connecting to the Database +# Connecting to the Database Use the Dial() function to create a new client for interacting with BoltDB. - var db hord.Database - db, err := bbolt.Dial(bbolt.Config{}) - if err != nil { - // Handle connection error - } + var db hord.Database + db, err := bbolt.Dial(bbolt.Config{}) + if err != nil { + // Handle connection error + } -Initialize database +# Initialize database Hord provides a Setup() function for preparing a database. This function is safe to execute after every Dial(). - err := db.Setup() - if err != nil { - // Handle setup error - } + err := db.Setup() + if err != nil { + // Handle setup error + } -Database Operations +# Database Operations Hord provides a simple abstraction for working with BoltDB, with easy-to-use methods such as Get() and Set() to read and write values. - // Connect to the BoltDB database - db, err := bbolt.Dial(bbolt.Config{}) - if err != nil { - // Handle connection error - } - - err := db.Setup() - if err != nil { - // Handle setup error - } - - // Set a value - err = db.Set("key", []byte("value")) - if err != nil { - // Handle error - } - - // Retrieve a value - value, err := db.Get("key") - if err != nil { - // Handle error - } + // Connect to the BoltDB database + db, err := bbolt.Dial(bbolt.Config{}) + if err != nil { + // Handle connection error + } + + err := db.Setup() + if err != nil { + // Handle setup error + } + + // Set a value + err = db.Set("key", []byte("value")) + if err != nil { + // Handle error + } + + // Retrieve a value + value, err := db.Get("key") + if err != nil { + // Handle error + } */ package bbolt diff --git a/drivers/cassandra/cassandra.go b/drivers/cassandra/cassandra.go index c98435f..32892a1 100644 --- a/drivers/cassandra/cassandra.go +++ b/drivers/cassandra/cassandra.go @@ -3,56 +3,56 @@ Package cassandra provides a Hord database driver for Cassandra. Cassandra is a highly scalable, distributed database designed to handle large amounts of data across many commodity servers. To use this driver, import it as follows: - import ( - "github.com/madflojo/hord" - "github.com/madflojo/hord/cassandra" - ) + import ( + "github.com/madflojo/hord" + "github.com/madflojo/hord/cassandra" + ) -Connecting to the Database +# Connecting to the Database Use the Dial() function to create a new client for interacting with Cassandra. - var db hord.Database - db, err := cassandra.Dial(cassandra.Config{}) - if err != nil { - // Handle connection error - } + var db hord.Database + db, err := cassandra.Dial(cassandra.Config{}) + if err != nil { + // Handle connection error + } -Initialize database +# Initialize database Hord provides a Setup() function for preparing a database. This function is safe to execute after every Dial(). - err := db.Setup() - if err != nil { - // Handle setup error - } + err := db.Setup() + if err != nil { + // Handle setup error + } -Database Operations +# Database Operations Hord provides a simple abstraction for working with Cassandra, with easy-to-use methods such as Get() and Set() to read and write values. - // Connect to the Cassandra database - db, err := cassandra.Dial(cassandra.Config{}) - if err != nil { - // Handle connection error - } - - err := db.Setup() - if err != nil { - // Handle setup error - } - - // Set a value - err = db.Set("key", []byte("value")) - if err != nil { - // Handle error - } - - // Retrieve a value - value, err := db.Get("key") - if err != nil { - // Handle error - } + // Connect to the Cassandra database + db, err := cassandra.Dial(cassandra.Config{}) + if err != nil { + // Handle connection error + } + + err := db.Setup() + if err != nil { + // Handle setup error + } + + // Set a value + err = db.Set("key", []byte("value")) + if err != nil { + // Handle error + } + + // Retrieve a value + value, err := db.Get("key") + if err != nil { + // Handle error + } */ package cassandra diff --git a/drivers/hashmap/hashmap.go b/drivers/hashmap/hashmap.go index 8fa4435..8ccb873 100644 --- a/drivers/hashmap/hashmap.go +++ b/drivers/hashmap/hashmap.go @@ -3,56 +3,56 @@ Package hashmap provides a Hord database driver for an in-memory hashmap. The Hashmap driver is a simple, in-memory key-value store that stores data in a hashmap structure. To use this driver, import it as follows: - import ( - "github.com/madflojo/hord" - "github.com/madflojo/hord/hashmap" - ) + import ( + "github.com/madflojo/hord" + "github.com/madflojo/hord/hashmap" + ) -Connecting to the Database +# Connecting to the Database Use the Dial() function to create a new client for interacting with the hashmap driver. - var db hord.Database - db, err := hashmap.Dial(hashmap.Config{}) - if err != nil { - // Handle connection error - } + var db hord.Database + db, err := hashmap.Dial(hashmap.Config{}) + if err != nil { + // Handle connection error + } -Initialize database +# Initialize database Hord provides a Setup() function for preparing a database. This function is safe to execute after every Dial(). - err := db.Setup() - if err != nil { - // Handle setup error - } + err := db.Setup() + if err != nil { + // Handle setup error + } -Database Operations +# Database Operations Hord provides a simple abstraction for working with the hashmap driver, with easy-to-use methods such as Get() and Set() to read and write values. - // Connect to the hashmap database - db, err := hashmap.Dial(hashmap.Config{}) - if err != nil { - // Handle connection error - } - - err := db.Setup() - if err != nil { - // Handle setup error - } - - // Set a value - err = db.Set("key", []byte("value")) - if err != nil { - // Handle error - } - - // Retrieve a value - value, err := db.Get("key") - if err != nil { - // Handle error - } + // Connect to the hashmap database + db, err := hashmap.Dial(hashmap.Config{}) + if err != nil { + // Handle connection error + } + + err := db.Setup() + if err != nil { + // Handle setup error + } + + // Set a value + err = db.Set("key", []byte("value")) + if err != nil { + // Handle error + } + + // Retrieve a value + value, err := db.Get("key") + if err != nil { + // Handle error + } */ package hashmap diff --git a/drivers/nats/nats.go b/drivers/nats/nats.go index 34a31ec..66d7759 100644 --- a/drivers/nats/nats.go +++ b/drivers/nats/nats.go @@ -3,58 +3,58 @@ Package nats provides a Hord database driver for the NATS key-value store. The NATS driver allows interacting with the NATS key-value store, which is a distributed key-value store built on top of the NATS messaging system. To use this driver, import it as follows: - import ( - "github.com/madflojo/hord" - "github.com/madflojo/hord/nats" - ) + import ( + "github.com/madflojo/hord" + "github.com/madflojo/hord/nats" + ) -Connecting to the Database +# Connecting to the Database Use the Dial() function to create a new client for interacting with the NATS driver. - var db hord.Database - db, err := nats.Dial(nats.Config{}) - if err != nil { - // Handle connection error - } + var db hord.Database + db, err := nats.Dial(nats.Config{}) + if err != nil { + // Handle connection error + } -Initialize database +# Initialize database Hord provides a Setup() function for preparing the database. This function is safe to execute after every Dial(). - err := db.Setup() - if err != nil { - // Handle setup error - } + err := db.Setup() + if err != nil { + // Handle setup error + } -Database Operations +# Database Operations Hord provides a simple abstraction for working with the NATS driver, with easy-to-use methods such as Get() and Set() to read and write values. Here are some examples demonstrating common usage patterns for the NATS driver. - // Connect to the NATS database - db, err := nats.Dial(nats.Config{}) - if err != nil { - // Handle connection error - } - - err := db.Setup() - if err != nil { - // Handle setup error - } - - // Set a value - err = db.Set("key", []byte("value")) - if err != nil { - // Handle error - } - - // Retrieve a value - value, err := db.Get("key") - if err != nil { - // Handle error - } + // Connect to the NATS database + db, err := nats.Dial(nats.Config{}) + if err != nil { + // Handle connection error + } + + err := db.Setup() + if err != nil { + // Handle setup error + } + + // Set a value + err = db.Set("key", []byte("value")) + if err != nil { + // Handle error + } + + // Retrieve a value + value, err := db.Get("key") + if err != nil { + // Handle error + } */ package nats diff --git a/drivers/redis/redis.go b/drivers/redis/redis.go index adb21bc..a82b8cf 100644 --- a/drivers/redis/redis.go +++ b/drivers/redis/redis.go @@ -3,56 +3,56 @@ Package redis provides a Hord database driver for Redis. Redis is an open-source, in-memory data structure store that can be used as a database, cache, and message broker. To use this driver, import it as follows: - import ( - "github.com/madflojo/hord" - "github.com/madflojo/hord/redis" - ) + import ( + "github.com/madflojo/hord" + "github.com/madflojo/hord/redis" + ) -Connecting to the Database +# Connecting to the Database Use the Dial() function to create a new client for interacting with Redis. - var db hord.Database - db, err := redis.Dial(redis.Config{}) - if err != nil { - // Handle connection error - } + var db hord.Database + db, err := redis.Dial(redis.Config{}) + if err != nil { + // Handle connection error + } -Initialize database +# Initialize database Hord provides a Setup() function for preparing a database. This function is safe to execute after every Dial(). - err := db.Setup() - if err != nil { - // Handle setup error - } + err := db.Setup() + if err != nil { + // Handle setup error + } -Database Operations +# Database Operations Hord provides a simple abstraction for working with Redis, with easy-to-use methods such as Get() and Set() to read and write values. - // Connect to the Redis database - db, err := redis.Dial(redis.Config{}) - if err != nil { - // Handle connection error - } - - err := db.Setup() - if err != nil { - // Handle setup error - } - - // Set a value - err = db.Set("key", []byte("value")) - if err != nil { - // Handle error - } - - // Retrieve a value - value, err := db.Get("key") - if err != nil { - // Handle error - } + // Connect to the Redis database + db, err := redis.Dial(redis.Config{}) + if err != nil { + // Handle connection error + } + + err := db.Setup() + if err != nil { + // Handle setup error + } + + // Set a value + err = db.Set("key", []byte("value")) + if err != nil { + // Handle error + } + + // Retrieve a value + value, err := db.Get("key") + if err != nil { + // Handle error + } */ package redis diff --git a/hord.go b/hord.go index 89b51e8..ec38a08 100644 --- a/hord.go +++ b/hord.go @@ -1,63 +1,63 @@ /* Package hord provides a simple and extensible interface for interacting with various database systems in a uniform way. -Overview +# Overview Hord is designed to be a database-agnostic library that provides a common interface for interacting with different database systems. It allows developers to write code that is decoupled from the underlying database technology, making it easier to switch between databases or support multiple databases in the same application. -Usage +# Usage To use Hord, import it as follows: - import "github.com/madflojo/hord" + import "github.com/madflojo/hord" -Creating a Database Client +# Creating a Database Client To create a database client, you need to import and use the appropriate driver package along with the `hord` package. For example, to use the Redis driver: - import ( - "github.com/madflojo/hord" - "github.com/madflojo/hord/redis" - ) + import ( + "github.com/madflojo/hord" + "github.com/madflojo/hord/redis" + ) - func main() { - var db hord.Database - db, err := redis.Dial(redis.Config{}) - if err != nil { - // Handle connection error - } + func main() { + var db hord.Database + db, err := redis.Dial(redis.Config{}) + if err != nil { + // Handle connection error + } - // Use the db client for database operations - // ... - } + // Use the db client for database operations + // ... + } Each driver provides its own `Dial` function to establish a connection to the database. Refer to the specific driver documentation for more details. -Database Operations +# Database Operations Once you have a database client, you can use it to perform various database operations. The API is consistent across different drivers. - // Set a value - err = db.Set("key", []byte("value")) - if err != nil { - // Handle error - } + // Set a value + err = db.Set("key", []byte("value")) + if err != nil { + // Handle error + } - // Retrieve a value - value, err := db.Get("key") - if err != nil { - // Handle error - } + // Retrieve a value + value, err := db.Get("key") + if err != nil { + // Handle error + } Refer to the `hord.Database` interface documentation for a complete list of available methods. -Error Handling +# Error Handling Hord provides common error types and constants for consistent error handling across drivers. Refer to the `hord` package documentation for more information on error handling. -Contributing +# Contributing Contributions to Hord are welcome! If you want to add support for a new database driver or improve the existing codebase, please refer to the contribution guidelines in the project's repository. */