Created
January 2, 2012 05:21
-
-
Save bradclawsie/1549455 to your computer and use it in GitHub Desktop.
loaddictionary.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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