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
+9.1k Golang : Intercept and compare HTTP response code example
+26.8k Golang : Find files by extension
+21.5k Golang : How to read float value from standard input ?
+11.5k Golang : Handle API query by curl with Gorilla Queries example
+17k Golang : Covert map/slice/array to JSON or XML format
+28.2k Golang : Connect to database (MySQL/MariaDB) server
+9.1k Golang : Get curl -I or head data from URL example
+43.5k Golang : Get hardware information such as disk, memory and CPU usage
+8.6k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+8.1k Golang : Multiplexer with net/http and map
+7.1k Javascript : How to get JSON data from another website with JQuery or Ajax ?
+14.3k Golang : Simple word wrap or line breaking example