Golang index.suffixarray.Lookup() function example

package index/suffixarray

Golang index.suffixarray.Lookup() function usage example

 package main

 import (
 "fmt"
 "index/suffixarray"
 "strings"
 )

 func main() {

 str := []string{"yum", "tasty", "taste good", "delicious", "sumptuous", "lavish", "palatable", "pleasant"}

 strByte := "\x00" + strings.Join(str, "\x00")

 index := suffixarray.New([]byte(strByte))

 searchkey := []string{"pleasant"} // change the lookup key here

 searchString := "\x00" + strings.Join(searchkey, "\x00")

 searchByte := []byte(searchString)

 result := index.Lookup(searchByte, -1)

 fmt.Println(result)

 }

Reference :

http://golang.org/pkg/index/suffixarray/#Index.Lookup

Advertisement