Fix index-out-of-range on empty string

Access to data[0] is not valid if len(data) == 0

This fails for me on go1.1beta . (Didn't test on go1.0)