Use as a starter template when building a new Go REST API with JWT authentication and MySQL persistence
Study how to structure a layered Go web app with middleware, service logic, and database model layers
Learn how to add Redis caching, Excel import/export, QR code generation, and image uploads to a Go API
Requires a running MySQL and Redis instance configured before the app will start.
go-gin-example is a working demonstration of how to build a backend web API in the Go programming language. The project models a blog system: it handles articles and tags, user authentication, file uploads, and extras like QR code generation and Excel import/export. It is intended as a reference showing how common building blocks fit together in a Go project, not as a finished product for direct deployment. The main technologies are Gin (a web framework for Go), GORM (a library that handles database interactions with MySQL), Redis (for caching frequently read data), JWT tokens (for authentication), and Swagger (for generating API documentation automatically). Each covers a distinct job: Gin manages HTTP routing, GORM reads and writes to MySQL, Redis reduces database load for popular queries, and JWT lets the server verify that a request comes from a logged-in user. The project is structured in layers. HTTP requests first pass through middleware that checks authentication, then reach route handlers that validate parameters and format responses, then delegate work to a service layer that holds business logic, and finally the service layer talks to models that interact with MySQL or the Redis cache. Beyond article and tag management, the codebase includes utilities for image uploads, generating QR codes embedded into poster images, reading and writing Excel files, and structured logging. These shared helpers live in a pkg/ directory so the rest of the code can import them cleanly. A Dockerfile and Makefile are included for build automation. The project uses Go modules for dependency management. The README notes it was written as a companion to a series of Chinese-language blog posts on building web services with Go, so some linked documentation is in Chinese.
← eddycjy on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.