¿Es este un grupo de hilos de trabajo idiomático en Go?

Estoy tratando de escribir un grupo de trabajadores simple con gorutinas.

¿Es el código que escribí idiomático? Si no, ¿qué debería cambiar?Quiero poder establecer el número máximo de subprocesos de trabajo en 5 y bloquear hasta que un trabajador esté disponible si los 5 están ocupados. ¿Cómo ampliaría esto para tener solo un grupo de 5 trabajadores como máximo? ¿Engendro las 5 gorutinas estáticas y le doy a cadawork_channel?

código:

package main

import (
    "fmt"
    "math/rand"
    "sync"
    "time"
)

func worker(id string, work string, o chan string, wg *sync.WaitGroup) {
    defer wg.Done()
    sleepMs := rand.Intn(1000)
    fmt.Printf("worker '%s' received: '%s', sleep %dms\n", id, work, sleepMs)
    time.Sleep(time.Duration(sleepMs) * time.Millisecond)
    o <- work + fmt.Sprintf("-%dms", sleepMs)
}

func main() {
    var work_channel = make(chan string)
    var results_channel = make(chan string)

    // create goroutine per item in work_channel
    go func() {
        var c = 0
        var wg sync.WaitGroup
        for work := range work_channel {
            wg.Add(1)
            go worker(fmt.Sprintf("%d", c), work, results_channel, &wg)
            c++
        }
        wg.Wait()
        fmt.Println("closing results channel")
        close(results_channel)
    }()

    // add work to the work_channel
    go func() {
        for c := 'a'; c < 'z'; c++ {
            work_channel <- fmt.Sprintf("%c", c)
        }
        close(work_channel)
        fmt.Println("sent work to work_channel")
    }()

    for x := range results_channel {
        fmt.Printf("result: %s\n", x)
    }
}

Respuestas a la pregunta(2)

Su respuesta a la pregunta