Fix NaN appending
Fix NaN appending

If m2.Values has fewer values than m1.Values, and they both start at the
same time and have the same step size, we pad out m2.Values with NaN.
However, doing so by looping with

    for i := 0; i < len(m1.Values) - len(m2.Values); i++ {
        m2.Values = append(m2.Values, math.NaN)
    }

doesn't work, as len(m1.Values) - len(m2.Values) decreases by 1 on every
iteration of the loop (at least in the current version of Go).

This causes panics with index out of range in production on line 177,
when we check

    if m2.Values[i] != math.NaN { ... }

where the index i can go up to len(m1.Values) > len(m2.Values) - 1.

We could imagine doing something clever like

    for len(m1.Values) > len(m2.Values) { ... }

but the compiler might get smart enough in the future for that to bite
us. The only future-proof fix seems to be the kind of ugly one we have
here, but that's Go for you.

dgryski/carbonapi