(file string, handler func(string) bool)
| 70 | } |
| 71 | |
| 72 | func readFile(file string, handler func(string) bool) error { |
| 73 | contents, err := ioutil.ReadFile(file) |
| 74 | if err != nil { |
| 75 | return err |
| 76 | } |
| 77 | |
| 78 | reader := bufio.NewReader(bytes.NewBuffer(contents)) |
| 79 | |
| 80 | for { |
| 81 | line, _, err := reader.ReadLine() |
| 82 | if err == io.EOF { |
| 83 | break |
| 84 | } |
| 85 | if !handler(string(line)) { |
| 86 | break |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | return nil |
| 91 | } |
| 92 | |
| 93 | func strtoull(val string) (uint64, error) { |
| 94 | return strconv.ParseUint(val, 10, 64) |