A boilerplate for building modern backend applications using the Go Gin framework, integrated with TailwindCSS, Preline UI components, and live reloading with Air for rapid development.
Ensure the following tools are installed on your system:
Clone the Repository
git clone https://github.com/Forkan-dev/laragintempltail.git
cd laragintempltail
Set Up TailwindCSS
Navigate to the resources
directory where TailwindCSS is configured.
cd resources
npm install
This will install all required dependencies for TailwindCSS, including Preline components.
Initialize Air
Ensure you have Air installed globally. If not, install it using the following command:
go install github.com/cosmtrek/air@latest
Once installed, return to the root directory of the project and run:
air init
This will create an .air.toml
configuration file. The air
configuration is already included in the repository, so you should not need to modify it.
Run the Application
Start the live reload server using Air:
air
Your application will be running at http://localhost:8080
by default.
├── main.go # Entry point of the application
├── resources/ # Contains TailwindCSS configuration and assets
│ ├── tailwind.config.js # TailwindCSS configuration file
│ ├── package.json # NPM configuration file
│ └── ... # Other assets
├── views/ # HTML templ templates for the application
├── public/ # Static files (CSS, JS, images)
├── routes/ # Gin route definitions web
├── app/ # Handlers for routes, middleware etc
└── .air.toml # Air configuration for live reloading
To customize the TailwindCSS configuration, modify the tailwind.config.js
file located in the resources
folder. After making changes, rebuild the CSS by running:
npm run build
Alternatively, use npm run watch
for automatic rebuilds during development.
Air watches your Go files and automatically reloads the server upon detecting changes. To use it:
main.go
is correctly set up as the entry point.air
from the root directory.Build the Application
Use the Go build command to create a production-ready binary:
go build -o app .
Static Assets
Ensure all TailwindCSS and static assets are built before deployment:
npm run build
Run the Application
Start the compiled binary:
./app
Contributions are welcome! Please fork the repository, make changes, and submit a pull request for review.
This project is licensed under the MIT License. See the LICENSE file for details.
Happy coding!