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 :

http://golang.org/pkg/index/suffixarray/#Index.Write

Advertisement