Skip to content

An example go + sqlite implementation for single user table exposing rest APIs for all CRUD operation.

Notifications You must be signed in to change notification settings

esafwan/go_sqlite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go SQLite REST API Example

This repository contains an example of a RESTful API implemented in Go, using SQLite as the database. It demonstrates basic CRUD (Create, Read, Update, Delete) operations on a user entity and showcases quick and efficient setup for REST APIs in Go.

Features

  • Basic CRUD operations for a user entity.
  • SQLite database integration.
  • Pagination support for list queries.
  • RESTful endpoints accessible via tools like Postman.

Getting Started

Prerequisites

  • Go (version 1.x)
  • SQLite3

Installation

  1. Clone the repository:
    git clone https://github.com/esafwan/go_sqlite
    
  2. Navigate to the project directory:
    cd your-repo-name
  3. Install dependencies (if any):
    go mod tidy

Running the Application

  1. Start the server:
    go run main.go
  2. The server will start on localhost:8080. You can interact with the API using tools like Postman or cURL.

API Endpoints

User CRUD Operations

  • List Users (GET /users)
    • Supports pagination with query parameters page and perPage.
  • Add User (POST /users)
    • Accepts JSON body with name, age, and class.
  • Edit User (PUT /users/{id})
    • Accepts JSON body with name, age, and class.
  • Delete User (DELETE /users/{id})
    • Deletes the user with the specified ID.

Project Structure

  • main.go: The entry point of the application, setting up the server and routes.
  • user/user.go: Contains the user model and handlers for CRUD operations.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

License

This project is licensed under the MIT License.

About

An example go + sqlite implementation for single user table exposing rest APIs for all CRUD operation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages