Table of content
Advanced Go skills for concurrency, error handling, and interfaces.
Installation
npx claude-plugins install @TheBushidoCollective/han/jutsu-go
Contents
Folders: hooks, scripts, skills
Files: CHANGELOG.md, README.md, han-plugin.yml
Documentation
Advanced Go skills for concurrency, error handling, and interfaces.
Skills
This plugin provides the following skills:
- Concurrency
- Error Handling
- Interfaces
Usage
Once enabled, Claude will automatically apply these skills when working with relevant code. The plugin provides context and expertise that Claude uses to:
- Write idiomatic code following best practices
- Suggest appropriate patterns and architectures
- Catch common mistakes and anti-patterns
- Provide framework-specific guidance
Installation
Install with npx (no installation required):
han plugin install jutsu-go
License
Licensed under MIT - see repository for details.
Included Skills
This plugin includes 3 skill definitions:
go-concurrency
Use when Go concurrency with goroutines, channels, and sync patterns. Use when writing concurrent Go code.
View skill definition
Go Concurrency
Master Go’s concurrency model using goroutines, channels, and synchronization primitives for building concurrent applications.
Goroutines
Creating goroutines:
package main
import (
"fmt"
"time"
)
func sayHello() {
fmt.Println("Hello from goroutine")
}
func main() {
// Launch goroutine
go sayHello()
// Anonymous function goroutine
go func() {
fmt.Println("Hello from anonymous goroutine")
}()
// Give goroutines time to execute
time.Sleep(time.Second)
}
Goroutines with parameters:
func printNumber(n int) {
fmt.Println(n)
}
func main() {
for i := 0; i < 10; i++ {
go printNumber(i)
}
time.Sleep(time.Second)
}
Channels
Basic channel operations:
func main() {
// Create unbuffered channel
ch := make(chan int)
// Send in goroutine (non-blocking)
go func() {
ch <- 42
}()
// Receive (blocks until value available)
value := <-ch
fmt.Println(value) // 42
}
Buffered channels:
func main() {
// Buffered channel with capacity 2
ch := make(chan string, 2)
// Can send up to 2 values without blocking
ch <- "first"
ch <- "second"
fmt.Println(<-ch) // first
fmt.Println(<-ch) // second
}
Channel direction:
// Send-only channel
func send(ch chan<- int) {
ch <- 42
}
// Receive-only channel
func receive(ch <-chan int) int {
return <-ch
}
func ma
...(truncated)
</details>
### go-error-handling
> Use when Go error handling with error wrapping, sentinel errors, and custom error types. Use when handling errors in Go applications.
<details>
<summary>View skill definition</summary>
# Go Error Handling
Master Go's error handling patterns including error wrapping, sentinel
errors, custom error types, and the errors package for robust applications.
## Basic Error Handling
**Creating and returning errors:**
```go
package main
import (
"errors"
"fmt"
)
func divide(a, b float64) (float64, error) {
if b == 0 {
return 0, errors.New("division by zero")
}
return a / b, nil
}
func main() {
result, err := divide(10, 0)
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Println("Result:", result)
}
Using fmt.Errorf:
func processFile(filename string) error {
if filename == "" {
return fmt.Errorf("filename cannot be empty")
}
// Process file...
return nil
}
Error Wrapping
Wrapping errors with context (Go 1.13+):
import (
"errors"
"fmt"
"os"
)
func readConfig(path string) error {
_, err := os.Open(path)
if err != nil {
return fmt.Errorf("failed to read config: %w", err)
}
return nil
}
func main() {
err := readConfig("config.json")
if err != nil {
fmt.Println(err)
// Output: failed to read config: open config.json: no such file
}
}
Unwrapping errors:
func handleError(err error) {
// Unwrap one level
unwrapped := errors.Unwrap(err)
if unwrapped != nil {
fmt.Println("Unwrapped:", unwrapped)
}
// Check if specific error is in chain
...(truncated)
</details>
### go-interfaces
> Use when Go interfaces including interface design, duck typing, and composition patterns. Use when designing Go APIs and abstractions.
<details>
<summary>View skill definition</summary>
# Go Interfaces
Master Go's interface system for creating flexible, decoupled code through
implicit implementation and composition patterns.
## Basic Interfaces
**Defining and implementing interfaces:**
```go
package main
import "fmt"
// Define interface
type Writer interface {
Write(p []byte) (n int, err error)
}
// Implement interface (implicit)
type ConsoleWriter struct{}
func (cw ConsoleWriter) Write(p []byte) (n int, err error) {
fmt.Print(string(p))
return len(p), nil
}
func main() {
var w Writer = ConsoleWriter{}
w.Write([]byte("Hello, World!\n"))
}
Multiple methods in interface:
type Reader interface {
Read(p []byte) (n int, err error)
}
type ReadWriter interface {
Read(p []byte) (n int, err error)
Write(p []byte) (n int, err error)
}
// Implement ReadWriter
type File struct {
name string
}
func (f *File) Read(p []byte) (n int, err error) {
// Implementation
return 0, nil
}
func (f *File) Write(p []byte) (n int, err error) {
// Implementation
return len(p), nil
}
Empty Interface
Using interface{} (any in Go 1.18+):
// Accepts any type
func printValue(v interface{}) {
fmt.Println(v)
}
// Modern syntax (Go 1.18+)
func printAny(v any) {
fmt.Println(v)
}
func main() {
printValue(42)
printValue("hello")
printValue(true)
printAny(3.14)
}
Type assertions:
func processValue(v interface{}) {
// Type assertion
if str, ok := v.(s
...(truncated)
</details>
## Source
[View on GitHub](https://github.com/TheBushidoCollective/han)