Skip to content

Instantly share code, notes, and snippets.

@Edison-Hsu
Created December 16, 2019 06:48
Show Gist options
  • Save Edison-Hsu/f6dd777bc8eca49ca638fe2dd19adb6e to your computer and use it in GitHub Desktop.
Save Edison-Hsu/f6dd777bc8eca49ca638fe2dd19adb6e to your computer and use it in GitHub Desktop.
golang_work_queue_example
func worker(jobChan <-chan Job) {
for job := range jobChan {
process(job)
}
}
// make a channel with a capacity of 100.
jobChan := make(chan Job, 100)
// start the worker
go worker(jobChan)
// enqueue a job
jobChan <- job
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment