diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-10-08 03:47:20 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-10-08 03:47:20 +0200 |
| commit | 78863857bddfc517291235133478c8a948f4b061 (patch) | |
| tree | 6b736ac92116f3c57db7057a8d850bde069fa5ee | |
| parent | f31c8c5fa9f11629abb9d357c47e24eb9a7c689c (diff) | |
| download | muxer-78863857bddfc517291235133478c8a948f4b061.tar.gz muxer-78863857bddfc517291235133478c8a948f4b061.zip | |
Update README
| -rw-r--r-- | README.md | 21 |
1 files changed, 5 insertions, 16 deletions
@@ -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 |
