func (h histogram) print() {
	total := 0
	for _, count := range h {
		total += count
	}
	i := 0
	percent := 100 / float64(total)
	for key, count := range h {
		fmt.Printf("%4d.  %5.2f%%  %5d  %s\n", i, float64(count)*percent, count, key)
		i++
	}
}
print the content of a histogram
package main
import (
	"fmt"
	"go/ast"
	"go/parser"
	"go/token"
	"io/ioutil"
	"path/filepath"
	"runtime"
	"strings"
)
func walk(dir string, f func(string) bool) bool {
	fis, err := ioutil.ReadDir(dir)
	if err != nil {
		panic(err)
	}
	for _, fi := range fis {
		path := filepath.Join(dir, fi.Name())
		if fi.IsDir() {
			if fi.Name() != "testdata" {
				if !walk(path, f) {
					return false
				}
			}
		} else if strings.HasSuffix(fi.Name(), ".go") && !strings.HasPrefix(fi.Name(), ".") {
			if !f(path) {
				return false
			}
		}
	}
	return true
}
func walkStdLib(f func(filename string) bool) {
	walk(filepath.Join(runtime.GOROOT(), "src"), f)
}
type histogram map[string]int
func (h histogram) add(filename string) {
	f, err := parser.ParseFile(token.NewFileSet(), filename, nil, 0)
	if err != nil {
		panic(err)
	}
	ast.Inspect(f, func(n ast.Node) bool {
		if n, ok := n.(ast.Stmt); ok {  
			h[fmt.Sprintf("%T", n)]++
		}
		return true
	})
}