Example #1
0
func main() {
	flag.Parse()
	if flag.NArg() < 1 {
		fmt.Println("Too few arguments")
		return
	}
	searchstr := flag.Arg(0)

	ps, err := pisearch.Open("pi1m")
	if err != nil {
		log.Fatal("Could not open pi:", err)
	}
	found, pos := ps.Search(0, searchstr)
	fmt.Println("Found? : ", found)
	fmt.Println("Pos? : ", pos)
	ps.Close()
}
Example #2
0
func main() {
	pisearch, err := pisearch.Open(pifile)
	if err != nil {
		log.Fatal("Could not open ", pifile, ": ", err)
	}
	server := &Piserver{pisearch}
	http.Handle("/piquery",
		jsonhandler(func(req *http.Request, respmap map[string]interface{}) {
			server.ServeQuery(req, respmap)
		}))
	http.Handle("/pidigits",
		jsonhandler(func(req *http.Request, respmap map[string]interface{}) {
			server.ServeDigits(req, respmap)
		}))

	werr := http.ListenAndServe(":1415", nil)
	if werr != nil {
		log.Fatal("ListenAndServe: ", err)
	}
}