Esempio n. 1
0
func staticPage(fileName string) (string, error) {
	lines, err := myio.ReadLines(fileName)
	if err != nil {
		return "", err
		//log.Fatalf("Could not find static page: %v", err)
	}
	return strings.Join(lines, "\n"), nil
}
Esempio n. 2
0
func (c *Checker) Initialize() {
	lines, err := myio.ReadLines(c.filePath)
	if err != nil {
		log.Fatalf("Could not read all words text file! %v", err)
	}
	//fmt.Printf("%v", lines)
	for _, line := range lines {
		// Keep track of what are actual words.
		c.wordMap[line] = true
		// Also fill the valid prefix map.
		s := []string{}
		for i := 0; i < len(line); i++ {
			s = append(s, string(line[i]))
			prefixLen := len(s)
			prefix := strings.Join(s, "")
			prefixMap, ok := c.prefixes[prefixLen]
			if !ok {
				c.prefixes[prefixLen] = make(map[string]bool)
				prefixMap = c.prefixes[prefixLen]
			}
			prefixMap[prefix] = true
		}
	}
}