Skip to content

Instantly share code, notes, and snippets.

@bradclawsie
Created January 2, 2012 05:21
Show Gist options
  • Save bradclawsie/1549455 to your computer and use it in GitHub Desktop.
Save bradclawsie/1549455 to your computer and use it in GitHub Desktop.
loaddictionary.go
package main
import (
"fmt"
"os"
"bufio"
memcache "github.com/bradfitz/gomemcache"
)
func main() {
f,err := os.Open("/etc/dictionaries-common/words")
if err != nil {
fmt.Println("open dict")
os.Exit(0)
}
defer f.Close()
r,err := bufio.NewReaderSize(f,256)
if err != nil {
fmt.Println("get reader")
os.Exit(0)
}
line,isPrefix,err := r.ReadLine()
mc := memcache.New("localhost:11212")
for err == nil && !isPrefix {
mc.Set(&memcache.Item{Key:string(line),Value:[]byte("1")})
line,isPrefix,err = r.ReadLine()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment