This creates some awkwardness. First of all, it just feels weird to have the result wrapped in a Snapshot type.
As it's implemented now, the caller cannot assume that the first value returned is non-nil even if the error is nil. This will require the API user to write code like
something, err := client.SomeService.All()
if err != nil {
// handle error
}
if something == nil {
// handle an empty snapshot
}
for s := range something.Snapshot {
While evaluating the v2 API I was wondering why many functions have a signature like
This creates some awkwardness. First of all, it just feels weird to have the result wrapped in a Snapshot type.
As it's implemented now, the caller cannot assume that the first value returned is non-nil even if the error is nil. This will require the API user to write code like
If the functions had a signature like:
It could be used more idiomatic like this:
1) Is there a reason that the Snapshot types are exposed for the end user? 2) Would you be interested in a pull request changing the API?
Issue type