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
+38.1k Golang : Read a text file and replace certain words
+15.9k Golang : Update database with GORM example
+11.5k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+13k Golang : Calculate elapsed years or months since a date
+5.4k Golang *File points to a file or directory ?
+12.1k Golang : md5 hash of a string
+15.6k Golang : Convert date format and separator yyyy-mm-dd to dd-mm-yyyy
+7.9k Javascript : Put image into Chrome browser's console
+7.9k Golang : Trim everything onward after a word
+9.4k Golang : Timeout example
+27.6k Golang : dial tcp: too many colons in address
+7.4k Golang : Scanf function weird error in Windows