commit 778eb357aad7d75b88a2da6d91dd3b62d7ffee6b
parent da90db34623d13ebd39ec60e94078105ff1e2c0c
Author: francoispqt <francois@parquet.ninja>
Date: Thu, 26 Apr 2018 12:56:43 +0800
stream decode remove pointer to channel
Diffstat:
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
@@ -122,12 +122,12 @@ Example of implementation with a channel:
```go
type ChannelString chan string
// implement UnmarshalerArray
-func (c *ChannelArray) UnmarshalArray(dec *gojay.Decoder) error {
+func (c ChannelArray) UnmarshalArray(dec *gojay.Decoder) error {
str := ""
if err := dec.AddString(&str); err != nil {
return err
}
- *c <- str
+ c <- str
return nil
}
```
@@ -143,12 +143,12 @@ Example:
```go
type ChannelStream chan *TestObj
// implement UnmarshalerStream
-func (c *ChannelStream) UnmarshalStream(dec *gojay.StreamDecoder) error {
+func (c ChannelStream) UnmarshalStream(dec *gojay.StreamDecoder) error {
obj := &TestObj{}
if err := dec.AddObject(obj); err != nil {
return err
}
- *c <- obj
+ c <- obj
return nil
}
@@ -159,7 +159,7 @@ func main() {
reader := getAnIOReaderStream()
dec := gojay.Stream.NewDecoder(reader)
// start decoding (will block the goroutine until something is written to the ReadWriter)
- go dec.DecodeStream(&streamChan)
+ go dec.DecodeStream(streamChan)
for {
select {
case v := <-streamChan:
diff --git a/decode_stream_test.go b/decode_stream_test.go
@@ -293,7 +293,7 @@ func runStreamTestCaseStrings(t *testing.T, testCase StreamTestString) {
testChan := ChannelStreamStrings(make(chan *string))
dec := Stream.NewDecoder(testCase.streamReader)
// start decoding (will block the goroutine until something is written to the ReadWriter)
- go dec.DecodeStream(&testChan)
+ go dec.DecodeStream(testChan)
// start writing to the ReadWriter
go testCase.streamReader.Write()
// prepare our result
@@ -312,12 +312,12 @@ loop:
type ChannelStreamStrings chan *string
-func (c *ChannelStreamStrings) UnmarshalStream(dec *StreamDecoder) error {
+func (c ChannelStreamStrings) UnmarshalStream(dec *StreamDecoder) error {
str := ""
if err := dec.AddString(&str); err != nil {
return err
}
- *c <- &str
+ c <- &str
return nil
}