Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1430)

Unified Diff: common/errors/multierror.go

Issue 1284323002: Make LazyMultiError only constructable via function (Closed) Base URL: https://github.com/luci/luci-go.git@master
Patch Set: fix doc Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « common/errors/lazymultierror_test.go ('k') | common/errors/multierror_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/errors/multierror.go
diff --git a/common/errors/multierror.go b/common/errors/multierror.go
index df812b643251d497f1f01b0a17014acb78b28687..1a051c4399b0e5dd68fb5993eb2e3ea3e8c05571 100644
--- a/common/errors/multierror.go
+++ b/common/errors/multierror.go
@@ -7,7 +7,6 @@ package errors
import (
"fmt"
"reflect"
- "sync"
)
var (
@@ -73,57 +72,6 @@ func MultiErrorFromErrors(ch <-chan error) error {
return ret
}
-// LazyMultiError is a lazily-constructed MultiError. You specify the target
-// MultiError size up front (as Size), and then you call Assign for each error
-// encountered, and it's potential index. The MultiError will only be allocated
-// if one of the Assign'd errors is non-nil. Similarly, Get will retrieve either
-// the allocated MultiError, or nil if no error was encountered.
-type LazyMultiError struct {
- sync.Mutex
-
- Size int
- me MultiError
-}
-
-// Assign semantically assigns the error to the given index in the MultiError.
-// If the error is nil, no action is taken. Otherwise the MultiError is
-// allocated to its full size (if not already), and the error assigned into it.
-//
-// It returns true iff err != nil.
-func (e *LazyMultiError) Assign(i int, err error) bool {
- if err == nil {
- return false
- }
- e.Lock()
- defer e.Unlock()
- if e.me == nil {
- e.me = make(MultiError, e.Size)
- }
- e.me[i] = err
- return true
-}
-
-// GetOne returns the error at the given index, or nil, if no non-nil error
-// was Assign'd.
-func (e *LazyMultiError) GetOne(i int) error {
- e.Lock()
- defer e.Unlock()
- if e.me == nil {
- return nil
- }
- return e.me[i]
-}
-
-// Get returns the MultiError, or nil, if no non-nil error was Assign'd.
-func (e *LazyMultiError) Get() error {
- e.Lock()
- defer e.Unlock()
- if e.me == nil {
- return nil
- }
- return e.me
-}
-
// Fix will convert a MultiError compatible type (e.g. []error) to this
// version of MultiError.
func Fix(err error) error {
« no previous file with comments | « common/errors/lazymultierror_test.go ('k') | common/errors/multierror_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698