bigtable: fix error variable shadowing bugs when tracing by named return
bigtable: fix error variable shadowing bugs when tracing by named return

Previously in bigtable.(*Table).Apply we started a span
and on defer ended with an error that had been previously
declared. However, in the body of that function, while
in the m.cond == nil scope, we shadowed the original error with:

    err := gax.Invoke

which means that regardless of the result of that newly
declared/shadowed "err" error, we would always end the span
with a success.

An illustration of this problem is:

  https://play.golang.org/p/1iesjtxGI-e

Using a named return parameter ensures that we always
capture the finally written error value, regardless of
shadowing or a new name at return time.

While here I examined a few usages of
func <func_name>(ctx context.Context) error {
    var err error
    ctx = trace.Startspan(ctx, <span_name>)
    defer func() { trace.EndSpan(ctx, err) }()

and changed them to:
func <func_name>(ctx context.Context) (err error) {
    ctx = trace.Startspan(ctx, <span_name>)
    defer func() { trace.EndSpan(ctx, err) }()

which will prevent the reported problem from creeping back in.

Change-Id: I63dd12486844b2fae9d946f895e5c85f80a3a3e1
Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/39651
Reviewed-by: kokoro <2ac7b1f3fa578934c95181d4272be0d3bca00121@google.com>
Reviewed-by: Jean de Klerk <605b93664484fed1e671a07bff68da39e73d0174@google.com>

googleapis/google-cloud-go,googleapis/google-cloud-go,googleapis/google-cloud-go,googleapis/google-cloud-go