aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2022-11-07 15:26:57 +0300
committerArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2022-11-07 15:26:57 +0300
commitf3887bdf8ac469db283d4a92a88edd6458812cbc (patch)
treef7e7d53dce90c060f80bcf66b20511da13ea701e /README.md
parentadd ReadStringLen(length int) func (diff)
downloadbitreader-f3887bdf8ac469db283d4a92a88edd6458812cbc.tar.gz
bitreader-f3887bdf8ac469db283d4a92a88edd6458812cbc.tar.bz2
bitreader-f3887bdf8ac469db283d4a92a88edd6458812cbc.zip
update readme for ReadStringLen()v1.2.1
Diffstat (limited to '')
-rw-r--r--README.md10
1 files changed, 6 insertions, 4 deletions
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
16```go 16```go
17import "github.com/pektezol/bitreader" 17import "github.com/pektezol/bitreader"
18 18
19// data: io.Reader Data to read from a io stream 19// data: io.Reader Data to read from an io stream
20// le: bool Little-endian(true) or big-endian(false) state 20// le: bool Little-endian(true) or big-endian(false) state
21reader := bitreader.Reader(data, le) 21reader := bitreader.Reader(data, le)
22 22
@@ -32,10 +32,12 @@ value, err := reader.ReadBytes(4)
32value, err := reader.ReadBits(64) // up to 64 bits 32value, err := reader.ReadBits(64) // up to 64 bits
33 33
34// Read String 34// Read String
35value, err := reader.ReadString() // null-terminated 35text, err := reader.ReadString() // null-terminated
36text, err := reader.ReadStringLen(256) // length-specified
36 37
37// Wrapper functions 38// Wrapper functions
38text := reader.ReadString() // string 39text := reader.TryReadString() // string
40text := reader.TryReadStringLen(64) // string
39state := reader.TryReadBool() // bool 41state := reader.TryReadBool() // bool
40value := reader.TryReadInt1() // uint8 42value := reader.TryReadInt1() // uint8
41value := reader.TryReadInt8() // uint8 43value := reader.TryReadInt8() // uint8
@@ -47,7 +49,7 @@ value := reader.TryReadFloat64() // float64
47``` 49```
48 50
49## Error Handling 51## Error Handling
50ReadBits(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. \ 52ReadBits(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. \
51Wrapper functions, however, only returns the value and panics if an error is encountered. 53Wrapper functions, however, only returns the value and panics if an error is encountered.
52 54
53## Bug Report / Feature Request 55## Bug Report / Feature Request