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.

referencesWEB服务开发服务配置服务配置-配置文件模板.md

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

所有的配置项请参考 ServerConfig 对象属性: https://pkg.go.dev/github.com/gogf/gf/v2/net/ghttp#ServerConfig

以下为配置文件模板:

server:
    # 基本配置
    address:             ":80"                 # 本地监听地址。默认":80",多个地址以","号分隔。例如:"192.168.2.3:8000,10.0.3.10:8001"
    httpsAddr:           ":443"                # TLS/HTTPS配置,同时需要配置证书和密钥。默认关闭。配置格式同上。
    httpsCertPath:       ""                    # TLS/HTTPS证书文件本地路径,建议使用绝对路径。默认关闭
    httpsKeyPath:        ""                    # TLS/HTTPS密钥文件本地路径,建议使用绝对路径。默认关闭
    readTimeout:         "60s"                 # 请求读取超时时间,一般不需要配置。默认为60秒
    writeTimeout:        "0"                   # 数据返回写入超时时间,一般不需要配置。默认不超时(0)
    idleTimeout:         "60s"                 # 仅当Keep-Alive开启时有效,请求闲置时间。默认为60秒
    maxHeaderBytes:      "10240"               # 请求Header大小限制(Byte)。默认为10KB
    keepAlive:           true                  # 是否开启Keep-Alive功能。默认true
    serverAgent:         "GoFrame HTTP Server" # 服务端Agent信息。默认为"GoFrame HTTP Server"

    # 接口文档
    openapiPath: "/api.json" # OpenAPI接口文档地址
    swaggerPath: "/swagger"  # 内置SwaggerUI展示地址

    # 静态服务配置
    indexFiles:          ["index.html","index.htm"]   # 自动首页静态文件检索。默认为["index.html", "index.htm"]
    indexFolder:         false                        # 当访问静态文件目录时,是否展示目录下的文件列表。默认关闭,那么请求将返回403
    serverRoot:          "/var/www"                   # 静态文件服务的目录根路径,配置时自动开启静态文件服务。默认关闭
    searchPaths:         ["/home/www","/var/lib/www"] # 提供静态文件服务时额外的文件搜索路径,当根路径找不到时则按照顺序在搜索目录查找。默认关闭
    fileServerEnabled:   false                        # 静态文件服务总开关。默认false

    # Cookie配置
    cookieMaxAge:        "365d"             # Cookie有效期。默认为365天
    cookiePath:          "/"                # Cookie有效路径。默认为"/"表示全站所有路径下有效
    cookieDomain:        ""                 # Cookie有效域名。默认为当前配置Cookie时的域名

    # Sessions配置
    sessionMaxAge:       "24h"              # Session有效期。默认为24小时
    sessionIdName:       "gfsessionid"      # SessionId的键名名称。默认为gfsessionid
    sessionCookieOutput: true               # Session特性开启时,是否将SessionId返回到Cookie中。默认true
    sessionPath:         "/tmp/gsessions"   # Session存储的文件目录路径。默认为当前系统临时目录下的gsessions目录

    # 日志基本配置
    # 此配置类似nginx,主要对请求日志的记录
    logPath:             ""                 # 日志文件存储目录路径,建议使用绝对路径。默认为空,表示关闭
    logStdout:           true               # 日志是否输出到终端。默认为true
    errorStack:          true               # 当Server捕获到异常时是否记录堆栈信息到日志中。默认为true
    errorLogEnabled:     true               # 是否记录异常日志信息到日志中。默认为true
    errorLogPattern:     "error-{Ymd}.log"  # 异常错误日志文件格式。默认为"error-{Ymd}.log"
    accessLogEnabled:    false              # 是否记录访问日志。默认为false
    accessLogPattern:    "access-{Ymd}.log" # 访问日志文件格式。默认为"access-{Ymd}.log"

    # 日志扩展配置(参数日志组件配置)
    # 此配置主要影响server(ghttp模块)日志,如web服务监听端口号、web服务路由,不会对 g.Log 产生影响
    logger:
        path:                  "/var/log/"           # 日志文件路径。默认为空,表示关闭,仅输出到终端
        file:                  "{Y-m-d}.log"         # 日志文件格式。默认为"{Y-m-d}.log"
        prefix:                ""                    # 日志内容输出前缀。默认为空
        level:                 "all"                 # 日志输出级别
        timeFormat:            "2006-01-02T15:04:05" # 自定义日志输出的时间格式,使用Golang标准的时间格式配置
        ctxKeys:               []                    # 自定义Context上下文变量名称,自动打印Context的变量到日志中。默认为空
        header:                true                  # 是否打印日志的头信息。默认true
        stdout:                true                  # 日志是否同时输出到终端。默认true
        rotateSize:            0                     # 按照日志文件大小对文件进行滚动切分。默认为0,表示关闭滚动切分特性
        rotateExpire:          0                     # 按照日志文件时间间隔对文件滚动切分。默认为0,表示关闭滚动切分特性
        rotateBackupLimit:     0                     # 按照切分的文件数量清理切分文件,当滚动切分特性开启时有效。默认为0,表示不备份,切分则删除
        rotateBackupExpire:    0                     # 按照切分的文件有效期清理切分文件,当滚动切分特性开启时有效。默认为0,表示不备份,切分则删除
        rotateBackupCompress:  0                     # 滚动切分文件的压缩比(0-9)。默认为0,表示不压缩
        rotateCheckInterval:   "1h"                  # 滚动切分的时间检测间隔,一般不需要设置。默认为1小时
        stdoutColorDisabled:   false                 # 关闭终端的颜色打印。默认开启
        writerColorEnable:     false                 # 日志文件是否带上颜色。默认false,表示不带颜色

    # PProf配置
    pprofEnabled: false # 是否开启PProf性能调试特性。默认为false
    pprofPattern: ""    # 开启PProf时有效,表示PProf特性的页面访问路径,对当前Server绑定的所有域名有效。

    # 平滑重启特性
    graceful:                false # 是否开启平滑重启特性,开启时将会在本地增加10000的本地TCP端口用于进程间通信。默认false
    gracefulTimeout:         2     # 父进程在平滑重启后多少秒退出,默认2秒。若请求耗时大于该值,可能会导致请求中断
    gracefulShutdownTimeout: 5     # 关闭Server时如果存在正在执行的HTTP请求,Server等待多少秒才执行强行关闭

    # 其他配置
    clientMaxBodySize:   810241024 # 客户端最大Body上传限制大小,影响文件上传大小(Byte)。默认为8*1024*1024=8MB
    formParsingMemory:   1048576   # 解析表单时的缓冲区大小(Byte),一般不需要配置。默认为1024*1024=1MB
    nameToUriType:       0         # 路由注册中使用对象注册时的路由生成规则。默认为0
    routeOverWrite:      false     # 当遇到重复路由注册时是否强制覆盖。默认为false,重复路由存在时将会在启动时报错退出
    dumpRouterMap:       true      # 是否在Server启动时打印所有的路由列表。默认为true

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.