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 :
Advertisement
Something interesting
Tutorials
+14.6k Golang : Missing Bazaar command
+7.7k Golang : Error reading timestamp with GORM or SQL driver
+9.1k Golang : Gonum standard normal random numbers example
+14.2k Golang : Convert IP version 6 address to integer or decimal number
+9.7k Golang : Load ASN1 encoded DSA public key PEM file example
+15.6k Golang : ROT47 (Caesar cipher by 47 characters) example
+29.4k Golang : JQuery AJAX post data to server and send data back to client example
+6.9k Fix sudo yum hang problem with no output or error messages
+18k Golang : Check if a directory exist or not
+10.1k Golang : Get login name from environment and prompt for password
+13.5k Golang : Read XML elements data with xml.CharData example