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组件列表编码解码经典哈希函数-ghash.md

基本介绍

常用经典哈希函数Go语言实现,提供 uint32 及 uint64 类型的哈希函数。

使用方式:

import "github.com/gogf/gf/v2/encoding/ghash"

接口文档:

https://pkg.go.dev/github.com/gogf/gf/v2/encoding/ghash

基准测试

goos: darwin
goarch: amd64
pkg: github.com/gogf/gf/v2/encoding/ghash
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Benchmark_BKDR
Benchmark_BKDR-12          39315165            26.88 ns/op
Benchmark_BKDR64
Benchmark_BKDR64-12        62891215            22.61 ns/op
Benchmark_SDBM
Benchmark_SDBM-12          49689925            25.40 ns/op
Benchmark_SDBM64
Benchmark_SDBM64-12        48860472            24.38 ns/op
Benchmark_RS
Benchmark_RS-12            39463418            25.52 ns/op
Benchmark_RS64
Benchmark_RS64-12         53318370            19.45 ns/op
Benchmark_JS
Benchmark_JS-12            53751033            23.20 ns/op
Benchmark_JS64
Benchmark_JS64-12          62440287            19.25 ns/op
Benchmark_PJW
Benchmark_PJW-12           42439626            27.85 ns/op
Benchmark_PJW64
Benchmark_PJW64-12         37491696            33.28 ns/op
Benchmark_ELF
Benchmark_ELF-12           38034584            31.74 ns/op
Benchmark_ELF64
Benchmark_ELF64-12         44047201            27.58 ns/op
Benchmark_DJB
Benchmark_DJB-12           46994352            22.60 ns/op
Benchmark_DJB64
Benchmark_DJB64-12         61980186            19.19 ns/op
Benchmark_AP
Benchmark_AP-12            29544234            40.58 ns/op
Benchmark_AP64
Benchmark_AP64-12          28123783            42.48 ns/op

重复测试

测试结果与测试内容有关联性和随机性,我这里通过 uint64 数值的范围遍历来进行简单的重复性测试,本身不够严谨,因此仅供趣味性参考。

package main

import (
    "encoding/binary"
    "fmt"
    "math"

    "github.com/gogf/gf/v2/encoding/ghash"
)

func main() {
    var (
        m    = make(map[uint64]struct{})
        b    = make([]byte, 8)
        ok   bool
        hash uint64
    )
    for i := uint64(0); i < math.MaxUint64; i++ {
        binary.LittleEndian.PutUint64(b, i)
        hash = ghash.PJW64(b)
        if _, ok = m[hash]; ok {
            fmt.Println("repeated found:", i)
            break
        }
        m[hash] = struct{}{}
    }
}

测试结果如下:

哈希函数 重复位置 备注
AP64 8388640
BKDR64 33536
DJB64 8448
ELF64 4096
JS64 734
PJW64 2
RS64 - 32G Memory OOM
SDBM64 - 32G Memory OOM

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.