HdrHistogram / hdrhistogram-go

A pure Go implementation of Gil Tene's HDR Histogram.
MIT License
435 stars 64 forks source link

Eliminate Panic? #19

Closed kylebrandt closed 8 years ago

kylebrandt commented 8 years ago

If any of the New methods receives a significant figure param outside the acceptable range the library will trigger a panic.

This makes the library unsuitable as-is for use cases that involve user input. From a consumer standpoint, this could be worked around by making a wrapper function that returns an error if the input isn't valid - but I think it would be cleaner to not have the library panic.

However, changing New to return an error will break the Libraries API, would you accept a PR for this?

codahale commented 8 years ago

You are correct that the API is unsuitable for arbitrary input. That is intentional. Just as you’d need to validate input to integer division, you need to validate input to this API.