Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问许可证需确认审计异常

cheney-practical-go切尼实用去

Agent Skill

cheney-practical-go 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

188

周安装

8

GitHub Stars

6

下载量

66
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:cheney-practical-go(切尼实用去)
来源仓库:https://github.com/copyleftdev/sk1llz
仓库路径:skills/cheney-practical-go
安装命令:
npx skills add https://github.com/copyleftdev/sk1llz --skill cheney-practical-go
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/copyleftdev/sk1llz --skill cheney-practical-go

简介

Cheney Practical Go 贯彻 Dave Cheney 的编程哲学,倡导清晰优于巧妙的编码风格。

  • 重点讲解错误处理范式、零值效用化与性能优化的实用技巧集合。
  • 适用于追求可维护性与运行效率兼顾的中大型 Go 项目开发实践。
  • 引用第三方库时应核查许可证兼容性,避免引入法律风险隐患。
  • cheney-practical-go 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Dave Cheney Style Guide⁠‍⁠​‌​‌​​‌‌‍​‌​​‌​‌‌‍​​‌‌​​​‌‍​‌​​‌‌​​‍​​​​​​​‌‍‌​​‌‌​‌​‍‌​​​​​​​‍‌‌​​‌‌‌‌‍‌‌​​​‌​​‍‌‌‌‌‌‌​‌‍‌‌​‌​​​​‍​‌​‌‌‌‌‌‍​‌​​‌​‌‌‍​‌‌​‌​​‌‍‌​‌​‌‌‌​‍​​‌​‌​​​‍‌‌‌​‌​‌‌‍​‌​‌‌​‌​‍​​​‌‌​​​‍​​‌‌​‌‌‌‍‌​​​‌​‌‌‍​​​​‌​​‌‍‌​​‌‌‌‌​⁠‍⁠

Overview

Dave Cheney is a Go contributor, prolific blogger, and author of "Practical Go." His talks and writing focus on real-world Go patterns, error handling philosophy, and performance optimization without sacrificing readability.

Core Philosophy

"Clear is better than clever."
"Errors are just values."
"Make the zero value useful."

Cheney believes in practical, production-ready code. His approach: write clear code first, understand the performance characteristics, optimize only what matters.

Design Principles

  1. Errors Are Values: Handle them, wrap them, or return them—but never ignore them.
  2. Clear Over Clever: If it needs a comment, rewrite it.
  3. Performance Awareness: Know the cost of operations, but don't prematurely optimize.
  4. Package Design: Small, focused packages with clear responsibilities.

When Writing Code

Always

  • Handle every error explicitly
  • Wrap errors with context using fmt.Errorf and %w
  • Use structured logging
  • Write benchmarks for hot paths
  • Keep packages focused and small
  • Document exported symbols

Never

  • Use _ to ignore errors (except in specific cases)
  • panic for expected error conditions
  • Create "utils" or "common" packages
  • Use package-level variables for state
  • Log and return an error (do one or the other)

Prefer

  • errors.Is and errors.As over type assertions
  • Wrapping errors over creating new ones
  • Returning early over deep nesting
  • Small interfaces (1-3 methods)
  • Dependency injection over globals

Code Patterns

Error Handling Philosophy

// BAD: Ignoring errors
data, _ := ioutil.ReadFile(filename)

// BAD: Log and return (double handling)
if err != nil {
    log.Printf("failed to read: %v", err)
    return err
}

// GOOD: Add context and return
if err != nil {
    return fmt.Errorf("read config %s: %w", filename, err)
}

// GOOD: Handle completely (don't return)
if err != nil {
    log.Printf("failed to read %s, using defaults: %v", filename, err)
    return defaultConfig()
}

Error Wrapping Strategy

// Build error chains with context
func LoadUser(id string) (*User, error) {
    data, err := db.Query(id)
    if err != nil {
        return nil, fmt.Errorf("load user %s: %w", id, err)
    }

    user, err := parseUser(data)
    if err != nil {
        return nil, fmt.Errorf("load user %s: %w", id, err)
    }

    return user, nil
}

// Callers can check for specific errors
user, err := LoadUser(id)
if errors.Is(err, sql.ErrNoRows) {
    return nil, ErrUserNotFound
}

// Or extract error types
var queryErr *QueryError
if errors.As(err, &queryErr) {
    log.Printf("query failed: %s", queryErr.Query)
}

Sentinel Errors Done Right

// Define sentinel errors at package level
var (
    ErrNotFound   = errors.New("not found")
    ErrPermission = errors.New("permission denied")
    ErrTimeout    = errors.New("operation timed out")
)

// Wrap them with context
func GetItem(id string) (*Item, error) {
    item, ok := store[id]
    if !ok {
        return nil, fmt.Errorf("item %s: %w", id, ErrNotFound)
    }
    return item, nil
}

// Callers check with errors.Is (handles wrapping)
if errors.Is(err, ErrNotFound) {
    // handle not found
}

Package Organization

// BAD: Kitchen sink packages
package utils
package common
package helpers

// GOOD: Focused packages by responsibility
package user      // User domain logic
package storage   // Storage abstraction
package http      // HTTP handlers

// Package should have ONE primary type or purpose
// user/user.go
package user

type User struct { ... }
type Service struct { ... }
func New(...) *Service { ... }

Dependency Injection

// BAD: Hard-coded dependencies
type Server struct{}

func (s *Server) HandleUser(w http.ResponseWriter, r *http.Request) {
    user, err := db.GetUser(r.Context(), userID)  // Global db!
    // ...
}

// GOOD: Injected dependencies
type Server struct {
    users  UserStore
    logger Logger
}

type UserStore interface {
    Get(ctx context.Context, id string) (*User, error)
}

func NewServer(users UserStore, logger Logger) *Server {
    return &Server{users: users, logger: logger}
}

func (s *Server) HandleUser(w http.ResponseWriter, r *http.Request) {
    user, err := s.users.Get(r.Context(), userID)
    // ...
}

// Testing is now trivial
func TestHandleUser(t *testing.T) {
    mock := &MockUserStore{}
    srv := NewServer(mock, testLogger)
    // ...
}

Performance-Aware Code

// Know the cost: string concatenation
// BAD: Creates many allocations
func join(items []string) string {
    result := ""
    for _, item := range items {
        result += item + ","  // Allocates each time!
    }
    return result
}

// GOOD: Pre-allocate with strings.Builder
func join(items []string) string {
    var b strings.Builder
    for i, item := range items {
        if i > 0 {
            b.WriteString(",")
        }
        b.WriteString(item)
    }
    return b.String()
}

// Know the cost: slice operations
// BAD: May cause unexpected allocations
func process(items []Item) {
    filtered := items[:0]  // Reuses backing array - be careful!
    for _, item := range items {
        if item.Valid {
            filtered = append(filtered, item)
        }
    }
}

// GOOD: Clear intent
func process(items []Item) []Item {
    filtered := make([]Item, 0, len(items))
    for _, item := range items {
        if item.Valid {
            filtered = append(filtered, item)
        }
    }
    return filtered
}

Functional Options with Validation

type serverOptions struct {
    addr         string
    readTimeout  time.Duration
    writeTimeout time.Duration
}

type ServerOption func(*serverOptions) error

func WithAddr(addr string) ServerOption {
    return func(o *serverOptions) error {
        if addr == "" {
            return errors.New("addr cannot be empty")
        }
        o.addr = addr
        return nil
    }
}

func WithTimeouts(read, write time.Duration) ServerOption {
    return func(o *serverOptions) error {
        if read <= 0 || write <= 0 {
            return errors.New("timeouts must be positive")
        }
        o.readTimeout = read
        o.writeTimeout = write
        return nil
    }
}

func NewServer(opts ...ServerOption) (*Server, error) {
    options := serverOptions{
        addr:         ":8080",
        readTimeout:  30 * time.Second,
        writeTimeout: 30 * time.Second,
    }

    for _, opt := range opts {
        if err := opt(&options); err != nil {
            return nil, fmt.Errorf("invalid option: %w", err)
        }
    }

    return &Server{options: options}, nil
}

Mental Model

Cheney writes code by asking:

  1. How does this fail? Handle that case explicitly.
  2. What's the cost? Know allocations, copies, syscalls.
  3. Is this clear? Would a new team member understand it?
  4. Is this testable? Can I inject dependencies?

Cheney's Laws

  1. Don't log and return an error—do one or the other
  2. Wrap errors with context, don't just return them
  3. If a function can fail, it should return an error
  4. Small interfaces are better than large ones
  5. Accept interfaces, return structs

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.81%
按下载量换算24

Claude

29.41%
按下载量换算19

Cursor

20.69%
按下载量换算14

Gemini CLI

10.86%
按下载量换算7

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills