diff --git a/README.md b/README.md index 2ef2045..cd462ef 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ cmds offers tools for describing and calling commands both locally and remotely, ## Documentation -https://godoc.org/github.com/ipfs/go-ipfs-cmds +https://pkg.go.dev/github.com/ipfs/go-ipfs-cmds ## Contribute @@ -30,4 +30,3 @@ This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/c ## License MIT - diff --git a/command_test.go b/command_test.go index 89f6074..5e83412 100644 --- a/command_test.go +++ b/command_test.go @@ -373,9 +373,9 @@ func TestEmitterExpectError(t *testing.T) { switch re.errorCount { case 0: - t.Errorf("expected SetError to be called") + t.Errorf("expected CloseWithError to be called") case 1: default: - t.Errorf("expected SetError to be called once, but was called %d times", re.errorCount) + t.Errorf("expected CloseWithError to be called once, but was called %d times", re.errorCount) } } diff --git a/doc.go b/doc.go index fde82c1..b160b72 100644 --- a/doc.go +++ b/doc.go @@ -60,10 +60,8 @@ from. Responses have a method Next() that returns the next emitted value and an error value. If the last element has been received, the returned error value is io.EOF. If the -application code has sent an error using SetError, the error -ErrRcvdError is returned on next, indicating that the caller -should call Error(). Depending on the reponse type, other -errors may also occur. +application's code encounters a fatal error, it will call CloseWithError, +and that the error value will be returned via subsiquent calls to Next(). # Pipes diff --git a/responseemitter.go b/responseemitter.go index 571c302..97d4438 100644 --- a/responseemitter.go +++ b/responseemitter.go @@ -41,7 +41,6 @@ type ResponseEmitter interface { CloseWithError(error) error // SetLength sets the length of the output - // err is an interface{} so we don't have to manually convert to error. SetLength(length uint64) // Emit sends a value. @@ -71,6 +70,7 @@ func Copy(re ResponseEmitter, res Response) error { } } +// EmitChan reads a value from a channel and send that value to re. func EmitChan(re ResponseEmitter, ch <-chan interface{}) error { for v := range ch { err := re.Emit(v)