goframe-v2
Installation
Summary
GoFrame v2 development conventions and component standards for Go services and APIs.
- Use
gf initto scaffold HTTP and microservice projects; auto-generated dao, do, and entity files must never be manually modified - Implement business logic directly in the
service/directory; avoid thelogic/directory unless explicitly required - Always use DO objects from
internal/model/do/for database operations; never useg.Mapormap[string]interface{}, and leverage nil field handling for conditional updates - Apply
gerrorfor all error handling to maintain complete stack traces; reuse existing components and methods before creating new ones - Reference included best practice examples for HTTP services, gRPC services, and project patterns
SKILL.md
Critical Conventions
Project Development Standards
- For complete projects (HTTP/microservices), install GoFrame CLI and use
gf initto create project scaffolding. See Project Creation - init for details. - Auto-generated code files (dao, do, entity) MUST NOT be manually created or modified per GoFrame conventions.
- Unless explicitly requested, do NOT use the
logic/directory for business logic. Implement business logic directly in theservice/directory. - Reference complete project examples:
- HTTP service best practice: user-http-service
- gRPC service best practice: user-grpc-service
Component Usage Standards
- Before creating new methods or variables, check if they already exist elsewhere and reuse existing implementations.
- Use the
gerrorcomponent for all error handling to ensure complete stack traces for traceability. - When exploring new components, prioritize GoFrame built-in components and reference best practice code from examples.
- Database Operations MUST use DO objects (
internal/model/do/), neverg.Mapormap[string]interface{}. DO struct fields areinterface{}; unset fields remainniland are automatically ignored by the ORM:// Good - use DO object dao.Users.Ctx(ctx).Where(cols.Id, id).Data(do.User{Uid: uid}).Update()