From d95317b840ff1b6a580c0a08757f5ca5f8308a7e Mon Sep 17 00:00:00 2001 From: gammazero <11790789+gammazero@users.noreply.github.com> Date: Tue, 13 May 2025 05:35:04 -1000 Subject: [PATCH 1/2] minor document updates --- README.md | 3 +-- command_test.go | 4 ++-- doc.go | 6 ++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2ef20450..cd462ef0 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 89f60748..5e834122 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 fde82c1c..b160b72d 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 From 4073cb4e29a0e57ec51f086ff12bc0191fdf591b Mon Sep 17 00:00:00 2001 From: gammazero <11790789+gammazero@users.noreply.github.com> Date: Tue, 13 May 2025 05:43:00 -1000 Subject: [PATCH 2/2] add comment --- responseemitter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/responseemitter.go b/responseemitter.go index 571c3022..97d4438c 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)