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.
- Basic CRUD operations for a user entity.
- SQLite database integration.
- Pagination support for list queries.
- RESTful endpoints accessible via tools like Postman.
- Go (version 1.x)
- SQLite3
- Clone the repository:
git clone https://github.com/esafwan/go_sqlite
- Navigate to the project directory:
cd your-repo-name
- Install dependencies (if any):
go mod tidy
- Start the server:
go run main.go
- The server will start on
localhost:8080
. You can interact with the API using tools like Postman or cURL.
- List Users (GET /users)
- Supports pagination with query parameters
page
andperPage
.
- Supports pagination with query parameters
- Add User (POST /users)
- Accepts JSON body with
name
,age
, andclass
.
- Accepts JSON body with
- Edit User (PUT /users/{id})
- Accepts JSON body with
name
,age
, andclass
.
- Accepts JSON body with
- Delete User (DELETE /users/{id})
- Deletes the user with the specified ID.
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.
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License.