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 : How to pipe input data to executing child process?
+48.1k Golang : How to convert JSON string to map and slice
+6.3k Golang : Detect face in uploaded photo like GPlus
+15.9k Golang : Get file permission
+11.3k Golang : How to use if, eq and print properly in html template
+13.4k Golang : Read from buffered reader until specific number of bytes
+7.6k Golang : Convert(cast) io.Reader type to string
+4.7k Javascript : Access JSON data example
+7.4k Golang : Convert source code to assembly language
+5k Golang : Constant and variable names in native language
+41.9k Golang : How do I convert int to uint8?
+7.2k Golang : Null and nil value