Fix lint (#357)
Fix lint left in
https://github.com/bazelbuild/remote-apis-sdks/pull/340
diff --git a/go/pkg/cache/singleflightcache.go b/go/pkg/cache/singleflightcache.go
index b4fe8b9..1a1db5c 100644
--- a/go/pkg/cache/singleflightcache.go
+++ b/go/pkg/cache/singleflightcache.go
@@ -35,6 +35,11 @@
}
// Load is similar to a sync.Map.Load.
+//
+// Callers must check loaded before val and err. Their value is meaninful only
+// if loaded is true. The err is not the last returned value because it would
+// likely lead the reader to think that err must be checked before loaded.
+//lint:ignore ST1008 loaded must be last, see above.
func (s *SingleFlight) Load(key interface{}) (val interface{}, err error, loaded bool) {
s.mu.RLock()
defer s.mu.RUnlock()
diff --git a/go/pkg/cas/upload.go b/go/pkg/cas/upload.go
index ae79d81..b09bfe6 100644
--- a/go/pkg/cas/upload.go
+++ b/go/pkg/cas/upload.go
@@ -147,7 +147,7 @@
// TODO(nodir): cache this syscall too.
info, err := os.Lstat(ps.Path)
if err != nil {
- return digest.Digest{}, err
+ return digest.Digest{}, errors.WithStack(err)
}
key := makeFSCacheKey(ps.Path, info.Mode().IsRegular(), ps.Exclude)
@@ -155,7 +155,7 @@
case !loaded:
return digest.Digest{}, errors.Wrapf(ErrNoDigest, "digest not found for %#v", ps)
case err != nil:
- return digest.Digest{}, err
+ return digest.Digest{}, errors.WithStack(err)
default:
return digest.NewFromProtoUnvalidated(val.(*digested).digest), nil
}
@@ -232,7 +232,8 @@
}
}
})
- return &UploadResult{Stats: u.stats, u: u}, eg.Wait()
+
+ return &UploadResult{Stats: u.stats, u: u}, errors.WithStack(eg.Wait())
}
// uploader implements a concurrent multi-stage pipeline to read blobs from the