This is an easy-to-use Map Reduce Go framework inspired by 2021 6.824 lab1.


  • Multiple workers on single machine right now.
  • Easy to parallel your code with just Map and Reduce function.


Here’s a simply example for word count program.


package main

import (
	mp ""

func main() {

And write down your own Map and Reduce function.


package main
import (

func Map(filename string, contents string, ctx worker.MrContext) {
	// function to detect word separators.
	ff := func(r rune) bool { return !unicode.IsLetter(r) }

	// split contents into an array of words.
	words := strings.FieldsFunc(contents, ff)

	for _, w := range words {
		ctx.EmitIntermediate(w, "1")
func Reduce(key string, values []string, ctx worker.MrContext) {
	// return the number of occurrences of this word.
	ctx.Emit(key, strconv.Itoa(len(values)))

Run with :

go build -race -buildmode=plugin -o wc.go
go run -race main.go -i 'txt/*' -p '' -r 1 -w 8

Output file name is mr-out-0.txt

More example can be found in the mrapps/ folder, and we will add more example in the future.

Made by Bo-Wei Chen. All code is
licensed under the MIT License.


View Github