func Bucketize(goroutines []Goroutine, similar Similarity) map[*Signature][]Goroutine {
	out := map[*Signature][]Goroutine{}
	for _, routine := range goroutines {
		found := false
		for key := range out {
			if key.Similar(&routine.Signature, similar) {
				found = true
				if !key.Equal(&routine.Signature) {
					newKey := key.Merge(&routine.Signature)
					out[newKey] = append(out[key], routine)
					delete(out, key)
				} else {
					out[key] = append(out[key], routine)
				}
				break
			}
		}
		if !found {
			key := &Signature{}
			*key = routine.Signature
			out[key] = []Goroutine{routine}
		}
	}
	return out
}
Bucketize returns the number of similar goroutines.
package stack
import (
	"sort"
)
type Similarity int
const (
	ExactFlags Similarity = iota
	ExactLines
	AnyPointer
	AnyValue
)