This project is a Boilerplate for Restful-API using Gin-Gonic and GORM for faster development by providing several common functions, such as:
- Service repository for every database models
- JWT Auth
- Logging
- Swagger Documentation
- Env loader
- Response Templating
- Migration & Seeder
- Etc.
Make sure you have the following installed on your machine:
- Go (version 1.20 or higher)
- Node.js (for the
dev
target in the Makefile with Nodemon)
-
Clone the repository:
git clone https://github.com/dimasbagusussilo/gin-golang-boilerplate.git
-
Change into the project directory:
cd gin-golang-boilerplate
-
Install project dependencies:
make deps
-
Rename file
.env.example
to.env
To compile the packages, run the following command:
make build
To build and run the project in development mode, use the following command:
make run
This will compile the packages and start the application.
To clean the project and remove previous builds, run:
make clean
To run the project in development mode using nodemon (requires Node.js), use the following command:
make dev
This will automatically restart the application whenever changes are made.
To generate API documentation using Swag, run:
make generatedocs1
This will create the documentation in the docs/v1/
directory.
To generate additional database migration file run:
make migrationcreate
This will create the migration file in the database/migrations/
directory.
We can run migration with Golang Migrate we can install with this command (mac):
brew install golang-migrate
Then we can run up migration with (we need setup credentials in Makefile
):
make migrateup
Same as up migration, we can run down migration with:
make migratedown
- Dimas Bagus Susilo [email protected]
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.# gin-golang-boilerplate