func suggestPackageContents(pkgPath, tokRoot, tok string) (cnt int) {
	name, pkg := parsePackage(pkgPath)
	if pkg == nil || (name == "main" && !showCmd) {
		return cnt
	}
	for _, c := range pkg.Consts {
		for _, n := range c.Names {
			cnt += suggestSymbol(tokRoot, tok, n)
		}
	}
	for _, v := range pkg.Vars {
		for _, n := range v.Names {
			cnt += suggestSymbol(tokRoot, tok, n)
		}
	}
	for _, f := range pkg.Funcs {
		cnt += suggestSymbol(tokRoot, tok, f.Name)
	}
	for _, t := range pkg.Types {
		cnt += suggestSymbol(tokRoot, tok, t.Name)
		for _, m := range t.Methods {
			cnt += suggestSymbol(tokRoot, tok, t.Name+"."+m.Name)
		}
	}
	return cnt
}
Parse a package and suggest all symbols found in it.
package main
import (
	"fmt"
	"go/build"
	"go/doc"
	"go/parser"
	"go/token"
	"io/ioutil"
	"log"
	"os"
	"path"
	"path/filepath"
	"strings"
	"unicode"
	"unicode/utf8"
)
var args []string
var matchCase = false
var unexported = false
var showCmd = false
func handleDoc(t *tokenizer) {
	if tok, old := t.Next(); old {
		switch tok {
		case "-c", "--c":
			matchCase = true
		case "-u", "--u":
			unexported = true
		case "-cmd", "--cmd":
			showCmd = true
		default:
			args = append(args, tok)
		}
		handleDoc(t)
	} else {
		if strings.Index(tok, "-") == 0 {
			for _, s := range []string{"-u", "-c", "-cmd"} {
				if strings.Index(s, tok) == 0 {
					fmt.Println(s + " ")
				}
			}
		} else {
			switch len(args) {
			case 0:
				relPkg := false
				if cwd, err := os.Getwd(); err == nil {
					relPkg = suggestPackageContents(cwd, "", tok) > 0
				}
				if len(tok) > 0 || !relPkg {
					suggestPackages(tok)
				}
				root, base := path.Split(tok)
				if i := strings.Index(base, "."); len(tok) > 0 && i > 0 {
					i += len(root)
					for _, pkgPath := range makePaths(tok[:i]) {
						tokRoot, tok := tok[:i+1], tok[i+1:]
						if suggestPackageContents(pkgPath, tokRoot, tok) > 0 {
							break
						}
					}
				}
			case 1:
				for _, pkgPath := range makePaths(args[0]) {
					if suggestPackageContents(pkgPath, "", tok) > 0 {
						break
					}
				}
			}
		}
	}
}