Golang index.suffixarray.Write() function example
package index/suffixarray
Golang index.suffixarray.Write() function usage example
package main
import (
"bytes"
"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))
buff := bytes.NewBuffer(nil)
fmt.Println("Length before write : ", buff.Len())
index.Write(buff)
fmt.Println("Length after write : ", buff.Len())
fmt.Printf("%s", string(buff.Bytes())) // won't be nice, but still human readable in a way
}
Reference :
Advertisement
Something interesting
Tutorials
+14.4k Golang : How to filter a map's elements for faster lookup
+7.1k Golang : Get Alexa ranking data example
+14.5k Golang : How to determine if user agent is a mobile device example
+7.9k Golang : How to feed or take banana with Gorilla Web Toolkit Session package
+43.2k Golang : Convert []byte to image
+5.6k PHP : Convert CSV to JSON with YQL example
+4.8k Golang : A program that contain another program and executes it during run-time
+9.3k Golang : Temperatures conversion example
+17.8k Golang : Defer function inside init()
+10.2k Golang : Text file editor (accept input from screen and save to file)
+8.7k Golang : Combine slices but preserve order example
+5.9k Golang : Use NLP to get sentences for each paragraph example