Пример #1
0
func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "usage: %s [options]\n", os.Args[0])
		flag.PrintDefaults()
		os.Exit(2)
	}

	flag.Parse()
	if *codegenPath == "" {
		flag.Usage()
	}

	codegenList, err := echoprint.ParseCodegenFile(*codegenPath)
	dieOrNah(err)

	err = echoprint.DBConnect()
	dieOrNah(err)
	defer echoprint.DBDisconnect()

	allMatches := echoprint.MatchAll(codegenList)

	for group, matches := range allMatches {
		log.Println("Matches for group ", group)
		for _, match := range matches {
			log.Printf("\t%+v", match)
		}
	}
}
Пример #2
0
func peformQuery(jsonData []byte) ([]queryResult, error) {
	codegenList, err := echoprint.ParseCodegen(jsonData)
	if err != nil {
		return nil, err
	}

	matchGroups := echoprint.MatchAll(codegenList)
	result := make([]queryResult, len(matchGroups))
	for i, group := range matchGroups {
		result[i] = newQueryResult(group)
	}

	debug.FreeOSMemory()
	return result, nil
}