Skip to content

totop275/go-starterkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Starter Kit

A Go starter kit with authentication, authorization, and essential features for building robust web applications.

Features

  • 🔐 Authentication & Authorization

    • JWT Authentication with refresh token
    • Role-based access control (RBAC)
    • Permission management
    • User management with OTP support
    • Token session management
  • 🌐 Internationalization

    • Multi-language support using go-playground/universal-translator
    • Easy language switching
    • Translation management
  • 📧 Email Service

    • Email templates
    • SMTP configuration using gomail
    • Email queue system
  • ⚙️ Configuration

    • Environment variables management using godotenv
    • Auto-loading .env files
    • Configuration validation
  • 🗄️ Database

    • PostgreSQL with GORM integration
    • Database migrations
    • Seeding support
  • 🛠️ Development Tools

    • Hot reload using Air
    • API documentation
    • Logging system
    • Error handling

Tech Stack

Prerequisites

  • Go 1.21 or higher
  • PostgreSQL

Getting Started

  1. Clone the repository & setup package name:
git clone https://github.com/totop275/go-starterkit.git
cd go-starterkit
rm -rf .git
find . -type f -name "*.go" -print0 | xargs -0 sed -i 's#totop275/go-starterkit#{your-name}/{project-name}#g'
sed -i 's#totop275/go-starterkit#{your-name}/{project-name}#g' go.mod
git init
  1. Install dependencies:
go mod download
  1. Copy the example environment file:
cp .env.example .env
  1. Update the .env file with your configuration:
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=password
DB_NAME=go_starterkit
JWT_SECRET=lO4m6p/zK1Q9Xy0/M3n8o7J6j5H4g3F2e1D0c9B8a7== #The JWT secret key must be a 256-bit (32-byte) Base64-encoded random string.

use this command to generate JWT_SECRET openssl rand -base64 32

  1. Run the application:
go run main.go

Or using Air for hot reload:

air

Seeding Demo Data

To seed demo users and credentials for testing:

# Seed the demo data
go run ./seeds/main.go

This will create the following demo users:

  1. Admin User:

You can use these credentials to test different user roles and permissions in the application.

API Documentation

The API documentation is available on Postman:

You can import the Postman collection to test the API endpoints directly.

Project Structure

.
├── app/                    # Application code
│   ├── handler/           # HTTP handlers
│   ├── middleware/        # HTTP middleware
│   └── models/           # Database models
├── config/                # Configuration files
├── resources/            # Static resources
├── routes/               # Route definitions
├── seeds/               # Database seeds
├── utils/               # Utility functions
├── .air.toml           # Air configuration
├── .env                # Environment variables
├── .env.example        # Example environment variables
├── go.mod             # Go module file
├── go.sum             # Go module checksum
└── main.go            # Main application file

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

About

A Go starter kit with authentication, authorization, and essential features for building robust web applications.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors