From f3887bdf8ac469db283d4a92a88edd6458812cbc Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Mon, 7 Nov 2022 15:26:57 +0300 Subject: update readme for ReadStringLen() --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 850678d..6cdb38c 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ $ go get github.com/pektezol/bitreader ```go import "github.com/pektezol/bitreader" -// data: io.Reader Data to read from a io stream +// data: io.Reader Data to read from an io stream // le: bool Little-endian(true) or big-endian(false) state reader := bitreader.Reader(data, le) @@ -32,10 +32,12 @@ value, err := reader.ReadBytes(4) value, err := reader.ReadBits(64) // up to 64 bits // Read String -value, err := reader.ReadString() // null-terminated +text, err := reader.ReadString() // null-terminated +text, err := reader.ReadStringLen(256) // length-specified // Wrapper functions -text := reader.ReadString() // string +text := reader.TryReadString() // string +text := reader.TryReadStringLen(64) // string state := reader.TryReadBool() // bool value := reader.TryReadInt1() // uint8 value := reader.TryReadInt8() // uint8 @@ -47,7 +49,7 @@ value := reader.TryReadFloat64() // float64 ``` ## Error Handling -ReadBits(x), ReadBytes(x), ReadBool(), ReadString(), SkipBits(x) and SkipBytes(x) functions returns an error message when they don't work as expected. It is advised to always handle errors. \ +ReadBits(x), ReadBytes(x), ReadBool(), ReadString(), ReadStringLen(x) SkipBits(x) and SkipBytes(x) functions returns an error message when they don't work as expected. It is advised to always handle errors. \ Wrapper functions, however, only returns the value and panics if an error is encountered. ## Bug Report / Feature Request -- cgit v1.2.3