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

基本介绍

资源管理 是指可以将任意文件/目录打包为 Golang 源码文件,并且编译到可执行文件中,随着可执行文件发布。

资源文件在程序启动时将会自解压释放到内存中,供程序只读访问,可以将它当做基于内存的文件管理器。同时, GoFrame 的资源管理特性也支持将文件/目录打包为独立的二进制资源文件使用。由于资源文件在程序运行时是基于内存的文件操作,没有磁盘 IO 的开销,因此其文件操作效率非常高。

使用方式:

import "github.com/gogf/gf/v2/os/gres"

接口文档:

https://pkg.go.dev/github.com/gogf/gf/v2/os/gres

组件特性

gres 资源管理组件具有以下显著特点:

  1. 可将任意的文件/目录打包为 Go 文件,支持自定义加解密。
  2. 打包的 Go 文件/资源文件自动压缩,常见 css/js 等文件可达到 50~90% 的压缩率。
  3. 支持对打包为 Go 文件的资源内容,方便地导出到本地文件系统。
  4. 资源管理器内容完全基于内存,并且内容只读,无法动态修改。
  5. 资源管理器默认整合支持到了 WebServer、配置管理、模板引擎模块中。
  6. 任意文件如网站静态文件、配置文件等可编译到二进制文件中,也可编译到发布的可执行文件中。
  7. 开发者可只需编译发布一个可执行文件,除了方便了软件分发,也为保护软件知识产权内容提供了可能。

与 embed.FS 的比较

从 Golang v1.16 版本开始官方提供了静态文件嵌入的 embed.FS 特性,整体底层设计和 gres 组件类似,压缩比、执行效率也差不多,只是在使用设计和工程化管理上有比较大的差别。 GoFrame 资源管理组件的功能更加丰富,框架的核心组件已经完全对接了 gres 资源管理组件,并且在 GoFrame 提供的标准的工程化管理下能够做到对开发者无感知地使用资源管理特性,具体可以参考章节 资源管理-最佳实践 。

未来 GoFrame 基础框架底层不会考虑内置对 embed.FS 组件的支持, embed.FS 与 gres 组件可以独立使用互不影响。

相关文档

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.