Skip to content

A simple Go REST API for managing a book collection. Features endpoints to add, update, list, and retrieve books using in-memory storage. Great for learning Go project structure, HTTP handlers, and basic CRUD operations.

Notifications You must be signed in to change notification settings

JeremyNRoos/Go-Book-Library-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BookLibrary

A simple RESTful API for managing a collection of books, built with Go. This project demonstrates a clean Go project structure, in-memory data storage, and basic HTTP handlers for CRUD operations.

Features

  • List Books: Retrieve all books in the library
  • Add Book: Add a new book to the collection
  • Get Book by ID: Fetch details of a specific book
  • Update Book: Edit the title and author of a book

Technologies

  • Language: Go 1.24+
  • Framework: net/http (standard library)
  • Data Storage: In-memory slice (no external DB)
  • API: RESTful endpoints (JSON)

Project Structure

BookLibrary/
├── cmd/
│   └── my_app/
│       └── main.go            # Application entry point
├── internal/
│   ├── database/
│   │   └── book_database.go   # Book struct & in-memory DB
│   └── handlers/
│       └── handler.go         # HTTP handlers for API
├── go.mod
└── README.md

Getting Started

Prerequisites

Running the Application

  1. Clone the repository:
    git clone <repo-url>
    cd Go-Book-Library-API
  2. Download dependencies:
    go mod tidy
  3. Run the server:
    cd cmd/my_app
    go run main.go
    The server will start on http://localhost:3333.

API Endpoints

  • GET /GetBooks — List all books
  • POST /AddBook — Add a new book (JSON body)
  • GET /GetBooks/{id} — Get a book by ID
  • PUT /PutBook/{id} — Update a book by ID (JSON body)

Example Book JSON

{
  "bookId": "string",
  "title": "string",
  "author": "string"
}

License

This project is licensed under the MIT License.

About

A simple Go REST API for managing a book collection. Features endpoints to add, update, list, and retrieve books using in-memory storage. Great for learning Go project structure, HTTP handlers, and basic CRUD operations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages