Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Go Hercule (thumbtack.com)
47 points by axk on June 27, 2014 | hide | past | favorite | 11 comments


Not sure if it was your intention, but your weekly update case will reset every time there is a manual update. I avoid time.After for recurring tasks in a select loop for this reason.

time.Ticker is great if you want to repeat the task at approximately the same interval. time.Timer is what I use when I want the task to repeat a certain time after the previous task has finished. You can also conveniently use timer.Reset(0) to trigger an immediate tick.


It's intentional. The update doesn't have to happen at the same time every week, we just wanted the model to be no more than 1 week old.

`time.Ticker` looks handy, I will definitely use it for another project.


FYI:

   for i, v := range array
will give you the indexes and values. If you just want the values then use "_" in place of i to "throwaway" the index.

http://play.golang.org/p/JZZ40FMOMz


The funny thing is that I knew it, but wrote `for v := range array` anyway at least a few times! My point is, it's not very intuitive. Thankfully, the compiler catches that, unless it's `[]int`.


The idea is it's `for k := range object` to iterate over the keys, and `for k, v := range object` to iterate over the keys and values, whether the object is a slice, array, map or string. The only exceptional case is a channel, which has no indices/keys.


It does make perfect sense, just goes against muscle memory from years of Python coding :)


> "Slicing past the end of array results in a runtime panic. Ignoring out of bound indices is more convenient (and consistent with how other languages handle this)."

Ignoring logic bugs sounds like a horrible idea


It's not always logic bugs. For example, here's how you would limit your slice to max N elements:

    arr = arr[:N]
...compared how it has to be done to avoid a panic:

    if len(arr) > N {
        arr = arr[:N]
    }
Not a big deal though, just slightly more verbose.


I'm clueless about what this is...

Can I use it? Is the source code available?


It wouldn't be very helpful, the algorithm and the problem are very specific to Thumbtack.

That being said, we plan to extract and free common code as we use Go for more projects. We love free / open source software!


Its an autocomplete for their search engine with machine learning.

I think its purely closed source based on the article.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: