aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-10-08 03:47:20 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-10-08 03:47:20 +0200
commit78863857bddfc517291235133478c8a948f4b061 (patch)
tree6b736ac92116f3c57db7057a8d850bde069fa5ee
parentf31c8c5fa9f11629abb9d357c47e24eb9a7c689c (diff)
downloadmuxer-78863857bddfc517291235133478c8a948f4b061.tar.gz
muxer-78863857bddfc517291235133478c8a948f4b061.zip
Update README
-rw-r--r--README.md21
1 files changed, 5 insertions, 16 deletions
diff --git a/README.md b/README.md
index c4c22bd..8d777aa 100644
--- a/README.md
+++ b/README.md
@@ -10,22 +10,9 @@ go get git.onurgunduz.com/muxer@latest
## Usage
-Go 1.25 or later is required. The examples below use these imports:
-
-```go
-import (
- "bufio"
- "bytes"
- "fmt"
- "log"
-
- "git.onurgunduz.com/muxer"
-)
-```
-
### Writing a message
-Create a writer around a `bufio.Writer`. This example writes to an in-memory buffer:
+Create a writer around a `bufio.Writer`.
```go
var output bytes.Buffer
@@ -55,7 +42,7 @@ fmt.Printf("%d %d %s\n", received.ID, received.Type, received.Data)
`ReadMessage` returns `io.EOF` when the source ends. The default buffer size is 4096 bytes; use `NewReaderSize` when messages need a larger buffer.
-The returned `Data` slice shares the reader's storage. Process it before the next read, or copy it with `append([]byte(nil), received.Data...)` if it needs to be kept.
+The returned `Data` slice shares the reader's storage. Process it before the next read.
### Using a TCP connection
@@ -79,7 +66,9 @@ if err := conn.ReadMessage(&response); err != nil {
fmt.Printf("%d %d %s\n", response.ID, response.Type, response.Data)
```
-`NewConn` wraps an accepted connection or another `io.ReadWriteCloser`. `Send` can write several messages at once and can be called concurrently. Use one reading goroutine per connection; direct `Reader` and `Writer` calls are not safe for concurrent use.
+`NewConn` wraps an accepted connection or another `io.ReadWriteCloser`.
+
+`Send` can write several messages at once and can be called concurrently. Use one reading goroutine per connection; direct `Reader` and `Writer` calls are not safe for concurrent use.
## Message structure