Attention: The code in this repository is intended for experimental use only and is not fully tested, documented, or supported by SingleStore. Visit the SingleStore Forums to ask questions about this repository.
This project demonstrates building a RESTful API for managing books using Golang and SingleStore. It follows test-driven development (TDD) principles and utilizes Testcontainers for efficient, reproducible testing.
- Go 1.22 or higher
- Docker
-
Set up the database:
- Create a SingleStore database.
- Create a
.env
file with the following environment variables:DB_USER
DB_PASSWORD
DB_HOST
DB_PORT
DB_NAME
-
Run the application:
go run main.go
The API will be available at http://localhost:8080
(or the port specified in your configuration).
GET /books
: Retrieve all booksGET /books/:id
: Retrieve a specific bookPOST /books
: Create a new bookPUT /books/:id
: Update an existing bookDELETE /books/:id
: Delete a book
To run the unit tests:
$ make test