From 138199ca17f47312c8faa4fcdc0bab20c5a1b850 Mon Sep 17 00:00:00 2001 From: Mark Rushakoff Date: Fri, 21 Apr 2023 11:25:13 -0400 Subject: [PATCH] Fix typo in unexported function name It looks like this was supposed to be "delim" write all -- "delitm" doesn't mean anything. Also skip casting the bytes slice to a string before formatting as %s, as the cast is redundant; and prefer %w for wrapping an error, for potential later use of errors.Is or errors.As. --- client.go | 4 ++-- multistream.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client.go b/client.go index 013dd5a..2aaecdc 100644 --- a/client.go +++ b/client.go @@ -55,7 +55,7 @@ func SelectProtoOrFail[T StringLike](proto T, rwc io.ReadWriteCloser) (err error errCh := make(chan error, 1) go func() { var buf bytes.Buffer - if err := delitmWriteAll(&buf, []byte(ProtocolID), []byte(proto)); err != nil { + if err := delimWriteAll(&buf, []byte(ProtocolID), []byte(proto)); err != nil { errCh <- err return } @@ -129,7 +129,7 @@ func SelectWithSimopenOrFail[T StringLike](protos []T, rwc io.ReadWriteCloser) ( werrCh := make(chan error, 1) go func() { var buf bytes.Buffer - if err := delitmWriteAll(&buf, []byte(ProtocolID), []byte(simOpenProtocol), []byte(protos[0])); err != nil { + if err := delimWriteAll(&buf, []byte(ProtocolID), []byte(simOpenProtocol), []byte(protos[0])); err != nil { werrCh <- err return } diff --git a/multistream.go b/multistream.go index 17e1ef7..9d11842 100644 --- a/multistream.go +++ b/multistream.go @@ -88,10 +88,10 @@ func delimWriteBuffered(w io.Writer, mes []byte) error { return bw.Flush() } -func delitmWriteAll(w io.Writer, messages ...[]byte) error { +func delimWriteAll(w io.Writer, messages ...[]byte) error { for _, mes := range messages { if err := delimWrite(w, mes); err != nil { - return fmt.Errorf("failed to write messages %s, err: %v ", string(mes), err) + return fmt.Errorf("failed to write messages %s, err: %w ", mes, err) } }