// the worker function run as a goroutine
the worker function run as a goroutine
// the worker function run as a goroutine
func grainWorker(wid uint64, inch chan dataEnvelope, outch chan dataEnvelope) {
	defer close(outch)
	var inDataTyped grainsData
	for inData := range inch {
		inDataTyped = inData.(grainsData)
		outData := grainsData{inDataTyped.local << 1, inDataTyped.total + (inDataTyped.local << 1), inDataTyped.msg + " " + strconv.FormatUint(wid, 10)}
		fmt.Println(wid, "- Received:", inDataTyped.local, inDataTyped.total, "- Sent:", outData)
		outch <- outData
	}
}
func grainWorker ( wid uint64 , inch chan dataEnvelope , outch chan dataEnvelope ) { defer close ( outch ) var inDataTyped grainsData for inData := range inch { inDataTyped = inData . ( grainsData ) outData := grainsData { inDataTyped . local << 1 , inDataTyped . total + ( inDataTyped . local << 1 ) , inDataTyped . msg + " " + strconv . FormatUint ( wid , 10 ) } fmt . Println ( wid , " " , inDataTyped . local , inDataTyped . total , " " , outData ) outch <- outData } }
the worker function run as a goroutine
the worker function run as a goroutine
// prepare the data for the next worker // send the data to the next worker