gorm-mysql-skill

Create standard GORM entity templates and configure MySQL read/write connections.

Updated Jan 24, 2026
One-click install
npx skills add https://github.com/Penitence1992/go-zero-backend-skills --skill gorm-mysql-skill
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gorm-mysql-skill
Source: https://github.com/Penitence1992/go-zero-backend-skills/tree/main/skills/gorm-mysql-skill
Command: npx skills add https://github.com/Penitence1992/go-zero-backend-skills --skill gorm-mysql-skill

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Streamlines creating consistent GORM models and MySQL access patterns across services, reducing boilerplate and errors.

Core Features & Use Cases

  • Standard entity templates with common fields (CreateTime, UpdateTime, CreateBy, UpdateBy).
  • Read-write separation guidance with environment-based configuration.
  • Example patterns for initializing service context and wiring DB connections.

Quick Start

Define a new Go struct in common-service/entity using the standard template, configure the MySQL read/write connections in etc/{{SERVICE}}.yaml, and initialize the connections in internal/svc/service_context.go.

Frequently Asked Questions about gorm-mysql-skill

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I standardize GORM model templates for MySQL in Go services?

Standardize GORM models by using entity templates with common auditing fields like CreateTime, UpdateTime, CreateBy, and UpdateBy to reduce boilerplate and ensure consistent MySQL data access patterns across Go services.

What is the best way to configure read-write separation for GORM MySQL connections?

Configure read-write separation in GORM by defining separate MySQL connection settings in your environment-based YAML configuration and wiring them into the initialization logic within your service context.

How do I set up service_context.go to initialize GORM MySQL database connections?

Set up service_context.go by using the provided initialization snippets to wire your MySQL database connections, applying the standard entity templates and configuration guidance to establish database access.

Can I use this GORM MySQL setup to enforce auditing fields across different Go services?

Yes, you can enforce auditing fields across Go services by applying the standard entity templates that automatically include common fields like CreateBy and UpdateBy for consistent database tracking.

Do I need specific dependencies to implement read-write separation with GORM in Go?

No specific external dependencies are required beyond the standard GORM library, as the setup provides configuration examples and initialization snippets to handle MySQL read-write separation directly in your Go service.

Why does my GORM MySQL entity template lack consistent auditing fields?

GORM MySQL entity templates lack consistent auditing fields when standard model patterns are not enforced, which this skill solves by providing templates with mandatory CreateTime, UpdateTime, CreateBy, and UpdateBy fields.