在 Manus 中运行任何 Skill
一键导入
一键导入
一键在 Manus 中运行任何 Skill
开始使用go-nil-interface
星标3
分支0
更新时间2025年12月18日 03:03
Interface nil trap - typed nil is not nil
安装
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
SKILL.md
readonly菜单
Interface nil trap - typed nil is not nil
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Handle hook scripts and paths for plugin packaging
Package claudefiles components into a valid Claude Code plugin
Package language-specific subsets of claudefiles
Plugin validation errors and fixes
Common channel patterns and idioms
Context cancellation patterns for graceful shutdown
| name | go-nil-interface |
| description | Interface nil trap - typed nil is not nil |
A typed nil pointer stored in an interface is NOT nil.
func GetUser(id int) error {
var err *MyError // typed nil
if id < 0 {
err = &MyError{"invalid id"}
}
return err // Returns non-nil interface containing nil pointer!
}
if err := GetUser(1); err != nil {
// This branch RUNS even though no error occurred
fmt.Println("error:", err)
}
func GetUser(id int) error {
if id < 0 {
return &MyError{"invalid id"}
}
return nil // Return untyped nil
}
if err := GetUser(1); err != nil {
// This branch does NOT run
fmt.Println("error:", err)
}
Interface contains (type, value). Typed nil has (type=*MyError, value=nil). This is different from (type=nil, value=nil).