Skip to content

Instantly share code, notes, and snippets.

@felixge
Last active November 2, 2015 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save felixge/f5c7e66b63a0d80e6258 to your computer and use it in GitHub Desktop.
Save felixge/f5c7e66b63a0d80e6258 to your computer and use it in GitHub Desktop.
known := map[string]struct{}{}
for {
ips := []string{}
if data, err := ioutil.ReadFile("ips.json"); err != nil {
time.Sleep(3 * time.Second)
continue
} else if err := json.Unmarshal(data, &ips); err != nil {
time.Sleep(3 * time.Second)
continue
}
for _, ip := range ips {
if _, ok := known[ip]; !ok {
known[ip] = struct{}{}
doSomething(ip)
}
}
time.Sleep(3 * time.Second)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment