All skills
gogf avatar

/goframe-v2

@911705d
by GoFramegogf/skills81 stars
3

GoFrame v2 development skill. Use only when the target Go project uses or is explicitly adopting GoFrame v2: the nearest go.mod requires github.com/gogf/gf/v2, existing Go files import github.com/gogf/gf/v2 or any github.com/gogf/gf/v2/... component package, or the user asks to scaffold, migrate, or build with GoFrame. Trigger for GoFrame-backed Go work such as APIs/controllers/services, middleware, routing/config, ORM/DAO/DO/entity/database operations, gf CLI/codegen, HTTP/gRPC services, and microservice conventions. Do not trigger for generic Go projects without GoFrame evidence, frontend-only work, shell scripts, or unrelated infrastructure tasks.

Use this Skill: https://skilld.dev/gh/gogf/skills/goframe-v2

This session only. Nothing lands on disk.

examplesregistrypolarisREADME.ZH.MD

≈795 tokens on demand. Your agent reads this file only when SKILL.md points to it.

注册中心 - Polaris 集成

简介

本示例演示了如何在 GoFrame 应用程序中集成 Polaris 服务注册中心。主要展示:

  • 使用 Polaris 注册服务
  • 使用 Polaris 发现服务
  • 实现服务健康检查
  • 构建分布式系统

目录结构

.
├── client/           # 客户端示例
│   └── client.go     # 基于Polaris的服务发现客户端实现
├── server/           # 服务器示例
│   └── server.go     # 基于Polaris的服务注册服务器实现
├── go.mod            # Go模块文件
└── go.sum            # Go模块校验和

功能特性

本示例展示了以下功能:

  1. 服务注册

    • 自动服务注册
    • 健康检查配置
    • 元数据管理
    • 服务路由
    • 限流控制
  2. 服务发现

    • 动态服务发现
    • 负载均衡
    • 故障转移支持
    • 熔断机制
    • 容错处理
  3. 协议支持

    • HTTP 服务
    • 自定义协议
    • 协议扩展

环境要求

  • Go 1.22 或更高版本
  • Polaris 服务器
  • 本地缓存目录读写权限

使用说明

  1. 配置 Polaris 服务器地址:

    conf := config.NewDefaultConfiguration([]string{"183.47.111.80:8091"})
  2. 配置本地缓存:

    conf.Consumer.LocalCache.SetPersistDir("/tmp/polaris/backup")
    api.SetLoggersDir("/tmp/polaris/log")
  3. 启动服务器:

    cd server
    go run server.go
  4. 运行客户端:

    cd client
    go run client.go

实现说明

  1. 服务器实现

    • 使用默认配置创建 Polaris 客户端
    • 配置本地缓存提升性能
    • 支持服务路由和限流配置
    • 提供健康检查和故障恢复
  2. 客户端实现

    • 自动服务发现和负载均衡
    • 支持熔断和容错机制
    • 本地缓存提供离线能力
    • 自动重试和故障转移

高级特性

  1. 本地缓存

    • 服务信息持久化
    • 离线运行支持
    • 性能优化
  2. 可靠性保障

    • 熔断保护
    • 限流控制
    • 故障转移
    • 容错处理

注意事项

  1. 确保配置正确的Polaris服务器地址
  2. 本地缓存目录需要有读写权限
  3. 建议开启日志记录便于调试
  4. 合理配置熔断和限流参数
  5. 注意监控服务健康状态

Source: SKILL.md on GitHub

1 alert16d5 checks · Risk MEDIUM
  • Gen Agent Trust Hub16d

    The skill provides a comprehensive development guide and code examples for the GoFrame v2 framework. While highly informative for Go developers, it contains several examples with hardcoded placeholder secrets, tokens, and specific local file paths to sensitive configuration files (like Kubernetes credentials). These elements are provided for demonstration purposes but represent insecure practices if used in production without modification.

  • Socket16d

    5 alerts: gptSecurity, gptAnomaly

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer6mo

    227/949 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 911705d. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 months ago.

Steadyupdated 4 months ago
  • Go
  • Database
  • goframe
  • orm
  • http
  • grpc
  • microservices
  • crud
  • scaffolding
  • middleware

README badge

README badge for gogf/skills

Provides instruction and conventions for developing with GoFrame v2, a modular Go framework for building HTTP and gRPC services, microservices, and database operations using its ORM, CLI tooling, and project scaffolding. Use this skill when the target project has GoFrame v2 as a dependency or when the user requests scaffolding, migrations, or service development with GoFrame conventions.

Generated from the current SKILL.md.

When should I use this skill?
Use this skill only when your Go project uses GoFrame v2, indicated by github.com/gogf/gf/v2 in go.mod or imports. Do not use for generic Go projects, frontend work, or infrastructure tasks unrelated to GoFrame.
Should I manually set created_at and updated_at fields?
No. GoFrame automatically writes created_at on insert and updated_at on insert/update/save. Manually setting these fields is redundant and violates project conventions.
What should I use for database operations instead of g.Map?
Always use DO objects from internal/model/do/. DO struct fields are interface{}, unset fields remain nil and are automatically ignored by the ORM.
How does soft delete work in GoFrame?
Call Delete() on the DAO; GoFrame automatically converts it to UPDATE SET deleted_at = NOW(). Queries automatically filter out soft-deleted rows without requiring manual WhereNull conditions.
Where should I implement business logic?
Implement business logic directly in the service/ directory. Do not use the logic/ directory unless explicitly requested.

Generated from the current SKILL.md. These answers refresh after source changes.