

Go Hercule - axk
http://www.thumbtack.com/engineering/go-hercule/

======
scarboy
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.

~~~
axk
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.

------
doragcoder
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](http://play.golang.org/p/JZZ40FMOMz)

~~~
axk
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`.

~~~
jnks
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.

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

------
Queue29
> "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

~~~
axk
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.

------
alixaxel
I'm clueless about what this is...

Can I use it? Is the source code available?

~~~
axk
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!

