go

Guide modern Go development covering idioms, layout, concurrency, generics, testing, and error handling.

Updated Jul 15, 2024
One-click install
npx skills add https://github.com/christian-deleon/dotfiles --skill go-christian-deleon
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go
Source: https://github.com/christian-deleon/dotfiles/tree/main/ai/skills/go
Command: npx skills add https://github.com/christian-deleon/dotfiles --skill go-christian-deleon

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gofumpt, golangci-lint, govulncheck, delve, goreleaser, sync, context, net/http, log/slog, errors, os, io, time, testing, net/url, compress/gzip, golang.org/x/sync/errgroup, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to modern Go development practices, covering idioms, layout, concurrency, generics, testing, and more. It helps developers write clean, efficient, and idiomatic Go code, reducing common pitfalls and promoting best practices.

Core Features & Use Cases

  • Modern Go Best Practices: Guidance on modern idioms, tooling, and best practices for writing Go code.
  • Layout and Organization: Instructions on organizing Go projects, including module structure, package layout, and file organization.
  • Concurrency: In-depth coverage of Go's concurrency primitives, including goroutines, channels, and synchronization mechanisms.
  • Error Handling: Best practices for error handling, including wrapping, inspecting, and aggregating errors.
  • Use Case: Imagine you are developing a web service in Go. This Skill can help you set up your project structure, implement concurrency safely, handle errors effectively, and utilize modern language features like generics and type aliases.

Quick Start

Run dot install to configure your Go environment and tools, then follow the guidelines for organizing your project, implementing concurrency, handling errors, and more.

Frequently Asked Questions about go

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

FAQPage Schema
What's the best way to structure a modern Go project for web services and CLIs?

Modern Go project structure utilizes idiomatic module and package layouts to separate concerns. Organizing files by domain and functionality ensures clean architecture for web services, CLIs, and libraries.

How do I handle errors in Go using wrapping and aggregating techniques?

Error handling in Go uses the errors package to wrap, inspect, and aggregate failures. Wrapping errors with contextual information allows for precise root cause identification and robust service failure management.

How does concurrency in Go work with goroutines and synchronization mechanisms?

Concurrency in Go uses goroutines and channels alongside the sync package for synchronization. This model enables efficient concurrent task execution while preventing data races in services.

How to use generics in Go for modern libraries?

Generics in modern Go allow writing flexible, type-safe functions and data structures for libraries. Using type parameters reduces code duplication while maintaining compile-time type safety.

Do I need golangci-lint and gofumpt to format and scan Go code?

You need golangci-lint and gofumpt to format and lint Go code. These tools enforce modern formatting standards and identify code issues before deployment.

Does this Go development guide support vulnerability scanning with govulncheck?

Modern Go development supports vulnerability scanning with govulncheck. This tool analyzes code dependencies to identify known security vulnerabilities in your services and libraries.