Back to Skills

go-concurrency

verified

Use when Go concurrency with goroutines, channels, and sync patterns. Use when writing concurrent Go code.

View on GitHub

Marketplace

han

TheBushidoCollective/han

Plugin

jutsu-go

Technique

Repository

TheBushidoCollective/han
60stars

jutsu/jutsu-go/skills/go-concurrency/SKILL.md

Last Verified

January 24, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/TheBushidoCollective/han/blob/main/jutsu/jutsu-go/skills/go-concurrency/SKILL.md -a claude-code --skill go-concurrency

Installation paths:

Claude
.claude/skills/go-concurrency/
Powered by add-skill CLI

Instructions

# Go Concurrency

Master Go's concurrency model using goroutines, channels, and synchronization
primitives for building concurrent applications.

## Goroutines

**Creating goroutines:**

```go
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:**

```go
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:**

```go
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:**

```go
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:**

```go
// Send-only channel
func send(ch chan<- int) {
    ch <- 42
}

// Receive-only channel
func receive(ch <-chan int) int {
    return <-ch
}

func main() {
    ch := make(chan int)

    go send(ch)
    value := receive(ch)

    fmt.Println(value)
}
```

**Closing channels:**

```go
func main() {
    ch := make(chan int, 3)

    ch <- 1
    ch <- 2
    ch <- 3
    close(ch) // Close channel

    // Receive until channel is closed
    for value := range ch {
        fmt.Println(value)
    }

    // Check if channel is closed
    value, ok := <-ch
    fmt.Printf("Value: %d, Open: %v\n", value, ok) // Value: 0, Open: false
}
```

## Select State

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
9215 chars