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
+11.2k Golang : Fix - does not implement sort.Interface (missing Len method)
+24.6k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+24.5k Golang : Change file read or write permission example
+5.1k Linux/Unix/MacOSX : Find out which application is listening to port 80 or use which IP version
+4.4k Golang : Valued expressions and functions example
+7.1k Nginx : How to block user agent ?
+9k Golang : Build and compile multiple source files
+21.2k Golang : How to force compile or remove object files first before rebuild?
+7.1k Golang : Get environment variable
+13.6k Golang : reCAPTCHA example
+16.1k Golang : How to check if input from os.Args is integer?
+12.5k Golang : "https://" not allowed in import path