packageutilimport(context"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context")// privateChanType protects the channel. Since this is a package-private type,// only methods defined in this package can get the error value from the// context.typeprivateChanTypechanerrorconsterrLogKey="the key used to extract the error log from the context"// ContextWithErrorLog returns a copy of parent and an error channel that can// be used to receive errors sent with the LogError method.funcContextWithErrorLog(parentcontext.Context)(context.Context,<-chanerror){errs:=make(privateChanType)ctx:=context.WithValue(parent,errLogKey,errs)returnctx,errs}// LogError logs the error to the owner of the context.//// If this context was created with ContextWithErrorLog, then this method// passes the error to context creator over an unbuffered channel.//// If this context was created by other means, this method is a no-op.funcLogError(ctxcontext.Context,errerror){v:=ctx.Value(errLogKey)errs,ok:=v.(privateChanType)if!ok{return}errs<-err}