https://github.com/nousefreak/go-parallel
Package go-parallel aims to simplify processing data in parallel by providing a small helper.
https://github.com/nousefreak/go-parallel
Last synced: about 1 year ago
JSON representation
Package go-parallel aims to simplify processing data in parallel by providing a small helper.
- Host: GitHub
- URL: https://github.com/nousefreak/go-parallel
- Owner: NoUseFreak
- License: mit
- Created: 2019-06-04T21:52:10.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-04T22:40:21.000Z (about 7 years ago)
- Last Synced: 2025-01-30T23:26:37.184Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-parallel
[](https://travis-ci.org/NoUseFreak/go-parallel) [](https://godoc.org/github.com/NoUseFreak/go-parallel)
Package go-parallel aims to simplify processing data in parallel by providing a small helper.
```go
package main
import (
"fmt"
"time"
"github.com/NoUseFreak/go-parallel"
)
type Payload struct {
Number int
}
func main() {
input := parallel.Input{}
for i := 0; i < 20; i++ {
input = append(input, Payload{Number: i})
}
p := parallel.Processor{Threads: 5}
result := p.Process(input, func(i interface{}) interface{} {
item := i.(Payload)
time.Sleep(1 * time.Second)
item.Number = item.Number * 2
return item
})
fmt.Printf("%v\n", result)
}
```