This project is a boilerplate template for building web applications using Go and the Fiber framework. It includes setup for database integration with PostgreSQL and provides a basic structure for implementing CRUD operations for user management.
- Docker
- Docker Compose
-
Clone the repository:
git clone https://github.com/karabayyazilim/go-fiber-boilerplate.git cd go-fiber-boilerplate
-
Install dependencies:
go mod tidy
-
Set up your environment variables. Create a
.env
file in the root directory and add the following:APP_PORT=8000 DB_HOST=localhost DB_PORT=5432 DB_NAME=go_fiber DB_USER=postgres DB_PASSWORD=postgres DB_SSL_MODE=disable DB_TIMEZONE=Europe/Istanbul
-
Start the PostgreSQL database using Docker Compose:
docker-compose up -d
-
Run the application:
go run src/cmd/app/main.go
-
The application will be available at
http://localhost:8000
.
src/internal/config
: Contains configuration files for the database.src/internal/models
: Contains the data models.src/internal/services
: Contains the service layer for business logic.src/pkg/paginate
: Contains pagination logic.
- GET /users: List all users with pagination.
- POST /users: Create a new user.
- GET /users/:id: Get a user by ID.
- PUT /users/:id: Update a user by ID.
- DELETE /users/:id: Delete a user by ID.