@@ -104,10 +104,11 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
104104| bool slice | y3.ToBoolSlice |
105105| string | y3.ToUTF8String |
106106| string slice | y3.ToUTF8StringSlice |
107+ | [ ] byte | y3.ToBytes |
107108
108109<details >
109110 <summary >struct</summary >
110-
111+
111112 ``` golang
112113 func main () {
113114 // Simulate source to generate and send data
@@ -137,7 +138,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
137138</details >
138139<details >
139140 <summary >struct slice</summary >
140-
141+
141142 ``` golang
142143 func main () {
143144 // Simulate source to generate and send data
@@ -170,7 +171,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
170171</details >
171172<details >
172173 <summary >int32</summary >
173-
174+
174175 ``` golang
175176 // Simulate source to generate and send data
176177 var data int32 = 123
@@ -192,7 +193,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
192193</details >
193194<details >
194195 <summary >int32 slice</summary >
195-
196+
196197 ``` golang
197198 // Simulate source to generate and send data
198199 data := []int32 {123 , 456 }
@@ -214,7 +215,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
214215</details >
215216<details >
216217 <summary >uint32</summary >
217-
218+
218219 ``` golang
219220 // Simulate source to generate and send data
220221 var data uint32 = 123
@@ -236,7 +237,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
236237</details >
237238<details >
238239 <summary >uint32 slice</summary >
239-
240+
240241 ``` golang
241242 // Simulate source to generate and send data
242243 data := []uint32 {123 , 456 }
@@ -258,7 +259,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
258259</details >
259260<details >
260261 <summary >int64</summary >
261-
262+
262263 ``` golang
263264 // Simulate source to generate and send data
264265 var data int64 = 123
@@ -280,7 +281,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
280281</details >
281282<details >
282283 <summary >int64 slice</summary >
283-
284+
284285 ``` golang
285286 // Simulate source to generate and send data
286287 data := []int64 {123 , 456 }
@@ -302,7 +303,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
302303</details >
303304<details >
304305 <summary >uint64</summary >
305-
306+
306307 ``` golang
307308 // Simulate source to generate and send data
308309 var data uint64 = 123
@@ -324,7 +325,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
324325</details >
325326<details >
326327 <summary >uint64 slice</summary >
327-
328+
328329 ``` golang
329330 // Simulate source to generate and send data
330331 data := []uint64 {123 , 456 }
@@ -346,7 +347,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
346347</details >
347348<details >
348349 <summary >float32</summary >
349-
350+
350351 ``` golang
351352 // Simulate source to generate and send data
352353 var data float32 = 1.23
@@ -368,7 +369,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
368369</details >
369370<details >
370371 <summary >float32 slice</summary >
371-
372+
372373 ``` golang
373374 // Simulate source to generate and send data
374375 data := []float32 {1.23 , 4.56 }
@@ -390,7 +391,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
390391</details >
391392<details >
392393 <summary >float64</summary >
393-
394+
394395 ``` golang
395396 // Simulate source to generate and send data
396397 var data float64 = 1.23
@@ -412,7 +413,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
412413</details >
413414<details >
414415 <summary >float64 slice</summary >
415-
416+
416417 ``` golang
417418 // Simulate source to generate and send data
418419 data := []float64 {1.23 , 4.56 }
@@ -434,7 +435,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
434435</details >
435436<details >
436437 <summary >bool</summary >
437-
438+
438439 ``` golang
439440 // Simulate source to generate and send data
440441 data := true
@@ -456,7 +457,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
456457</details >
457458<details >
458459 <summary >bool slice</summary >
459-
460+
460461 ``` golang
461462 // Simulate source to generate and send data
462463 data := []bool {true , false }
@@ -478,7 +479,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
478479</details >
479480<details >
480481 <summary >string</summary >
481-
482+
482483 ``` golang
483484 // Simulate source to generate and send data
484485 data := " abc"
@@ -500,7 +501,7 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
500501</details >
501502<details >
502503 <summary >string slice</summary >
503-
504+
504505 ``` golang
505506 // Simulate source to generate and send data
506507 data := []string {" a" , " b" }
@@ -520,6 +521,28 @@ Unified encoding method: `y3.NewCodec(observe byte).Marshal(input interface{})`
520521 }
521522 ```
522523</details >
524+ <details >
525+ <summary >[]byte</summary >
526+
527+ ``` golang
528+ // Simulate source to generate and send data
529+ data := []byte {0x20 , 0x21 , 0x22 }
530+ sendingBuf , _ := y3.NewCodec (0x10 ).Marshal (data)
531+ source := y3.FromStream (bytes.NewReader (sendingBuf))
532+ // Simulate flow listening and decoding data
533+ var decode = func (v []byte ) (interface {}, error ) {
534+ sl , err := y3.ToBytes (v)
535+ if err != nil {
536+ return nil , err
537+ }
538+ fmt.Printf (" encoded data: %#v \n " , sl)
539+ return sl, nil
540+ }
541+ consumer := source.Subscribe (0x10 ).OnObserve (decode)
542+ for range consumer {
543+ }
544+ ```
545+ </details >
523546
524547More examples in ` /examples/ `
525548
0 commit comments