golang-safety

Detect nil pointer dereferences, slice aliasing, and map concurrent access in Golang code.

23|1|Updated May 10, 2026
One-click install
npx skills add https://github.com/berksunduri/GOPost --skill golang-safety-berksunduri
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-safety
Source: https://github.com/berksunduri/GOPost/tree/main/.agents/skills/golang-safety
Command: npx skills add https://github.com/berksunduri/GOPost --skill golang-safety-berksunduri

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires errcheck, forcetypeassert, nilerr, govet, staticcheck, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill assists in identifying and preventing common Go programming pitfalls, such as nil pointer dereferences, slice aliasing, map concurrent access, float comparison issues, and zero-value design problems. It helps developers write more robust, predictable, and secure code.

Core Features & Use Cases

  • Nil Safety: Detects and prevents nil pointer dereferences, ensuring that your code handles nil values gracefully.
  • Slice and Map Safety: Avoids issues like slice aliasing, map concurrent access, and improper use of zero values.
  • Numeric Safety: Ensures that integer conversions and float arithmetic are handled safely to prevent overflow and precision errors.
  • Resource Safety: Manages resources effectively by avoiding leaks and ensuring proper initialization and cleanup.
  • Immutability and Defensive Copying: Promotes best practices for protecting data integrity and preventing data races.
  • Initialization Safety: Ensures that types and structures are initialized correctly to avoid unexpected behavior.
  • Use Case: Ideal for developers who want to review and improve their Golang codebase for safety, especially when dealing with concurrency, data handling, and error management.

Quick Start

Run the golang-safety skill on your code to identify potential nil safety issues.

Frequently Asked Questions about golang-safety

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent nil pointer dereferences in Golang?

Identify nil pointer dereferences in Golang by using linters like nilerr and govet to catch unsafe nil access. Apply defensive programming to ensure nil values are checked and handled gracefully before pointer operations occur.

How do I detect map concurrent access and slice aliasing issues in Go?

Detect map concurrent access and slice aliasing in Go by running static analysis tools like staticcheck and govet. They pinpoint unsafe concurrent map operations and improper slice sharing to improve code predictability.

What is the best way to handle unchecked errors in Golang code?

Handle unchecked errors in Golang by running the errcheck linter to identify ignored error returns. Enforcing proper error handling ensures program reliability and prevents silent failures during execution.

Does this approach work with standard Go linters like staticcheck and govet?

Yes, this safety approach works directly with standard Go linters like staticcheck and govet. It leverages their analysis alongside errcheck, forcetypeassert, and nilerr to comprehensively detect safety issues.

How do I fix float comparison and zero-value design problems in Go?

Fix float comparison and zero-value design problems in Go by applying defensive programming patterns. Static analysis identifies precision errors in float arithmetic and improper reliance on zero values during initialization.

When should I worry about type assertion panics in Golang?

Worry about type assertion panics in Golang whenever using unchecked type assertions. The forcetypeassert linter detects unsafe operations, allowing you to apply the comma-ok pattern and prevent runtime crashes.