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.

references微服务开发服务端配置.md

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

基本介绍

gRPC 服务端支持配置文件管理,所有的配置项将会自动映射到 GrpcServerConfig 配置对象中。配置对象定义如下:

// GrpcServerConfig is the configuration for server.
type GrpcServerConfig struct {
    Address          string              // (optional) Address for server listening.
    Name             string              // (optional) Name for current service.
    Logger           *glog.Logger        // (optional) Logger for server.
    LogPath          string              // (optional) LogPath specifies the directory for storing logging files.
    LogStdout        bool                // (optional) LogStdout specifies whether printing logging content to stdout.
    ErrorStack       bool                // (optional) ErrorStack specifies whether logging stack information when error.
    ErrorLogEnabled  bool                // (optional) ErrorLogEnabled enables error logging content to files.
    ErrorLogPattern  string              // (optional) ErrorLogPattern specifies the error log file pattern like: error-{Ymd}.log
    AccessLogEnabled bool                // (optional) AccessLogEnabled enables access logging content to file.
    AccessLogPattern string              // (optional) AccessLogPattern specifies the error log file pattern like: access-{Ymd}.log
    Endpoints        []string            // (optional) Endpoints are custom endpoints for service register, it uses Address if empty.
}

配置文件的自动读取逻辑与框架一致,详细介绍请参考章节: 配置管理

配置模板

一个完整的配置模板示例如下,包含基础配置和日志扩展配置:

grpc:
  name:             "demo"  # 服务名称
  address:          ":8000" # 自定义服务监听地址
  logPath:          "./log" # 日志存储目录路径
  logStdout:        true    # 日志是否输出到终端
  errorLogEnabled:  true    # 是否开启错误日志记录
  accessLogEnabled: true    # 是否开启访问日志记录
  errorStack:       true    # 当产生错误时,是否记录错误堆栈
  endpoints:        ["192.168.1.3:8000"] # 自定义服务注册地址列表

  # 日志扩展配置(参数日志组件配置)
  logger:
    path:                  "/var/log/"   # 日志文件路径。默认为空,表示关闭,仅输出到终端
    file:                  "{Y-m-d}.log" # 日志文件格式。默认为"{Y-m-d}.log"
    prefix:                ""            # 日志内容输出前缀。默认为空
    level:                 "all"         # 日志输出级别
    stdout:                true          # 日志是否同时输出到终端。默认true
    rotateSize:            0             # 按照日志文件大小对文件进行滚动切分。默认为0,表示关闭滚动切分特性
    rotateExpire:          0             # 按照日志文件时间间隔对文件滚动切分。默认为0,表示关闭滚动切分特性
    rotateBackupLimit:     0             # 按照切分的文件数量清理切分文件,当滚动切分特性开启时有效。默认为0,表示不备份,切分则删除
    rotateBackupExpire:    0             # 按照切分的文件有效期清理切分文件,当滚动切分特性开启时有效。默认为0,表示不备份,切分则删除
    rotateBackupCompress:  0             # 滚动切分文件的压缩比(0-9)。默认为0,表示不压缩
    rotateCheckInterval:   "1h"          # 滚动切分的时间检测间隔,一般不需要设置。默认为1小时

其中的日志配置与 HTTP Server 保持一致,可以独立使用日志组件的配置项来配置 gRPC Server 的日志。关于日志组件的详细配置说明,请参考文档: 日志组件-配置管理

注意事项

访问端口配置

在没有配置 address 的情况下, gRPC Server 将会使用本地网卡的所有 IP 地址加上随机空闲端口来启动(默认配置为 :0 )。如果想要指定 IP 地址但使用随机空闲端口启动 gRPC Server ,可以使用 ip:0 的格式来配置 address ,例如: 192.168.1.1:0 、 10.0.1.1:0 。

服务注册地址

服务注册地址用于对外提供服务发现和访问,可以通过 endpoints 配置项自定义服务注册地址。

在没有配置 endpoints 的情况下, gRPC Server 将会使用 address 的地址来注册服务。如果没有指定 address 配置,或者使用的是 0.0.0.0 的 address 配置,那么将会自动获取本机的所有局域网 IP 地址作为服务注册的地址。如果您对注册的地址有特定要求,可以通过 endpoints 自定义服务注册的地址。

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.