Search Gear 18 - Anonymous Functions and Closures
Now, I also need a function to process wildcards out of hashtags maybe creating multiple requests from a single tag.
Let’s go with anonymous functions and closures, which in flirted with on day 7, what seems like years ago now!
https://gobyexample.com/closures
func getItem(entries toml.Value) func() string { i := -1 return func() string { i += 1 if i
Then a function to loop ‘collect’ for each tag, user, and home.
Get Me! Parallel processing!
func (tw *twitter) GetTags() { nextItem := getItem(tw.tags) for { if entry := nextItem(); entry != "" { go tw.collect(entry) } else { break } } }
func (tw *twitter) GetUsers() { nextItem := getItem(tw.users) for { if entry := nextItem(); entry != "" { go tw.collect(entry) } else { break } } }
func (tw *twitter) GetHome() { tw.collect(“MyHome”) }
HUMM testing tomorrow.