forked from francoispqt/gojay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
encode_example_test.go
65 lines (55 loc) · 971 Bytes
/
encode_example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package gojay_test
import (
"fmt"
"log"
"os"
"github.com/francoispqt/gojay"
)
func ExampleMarshal_string() {
str := "gojay"
d, err := gojay.Marshal(str)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(d)) // "gojay"
}
func ExampleMarshal_bool() {
b := true
d, err := gojay.Marshal(b)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(d)) // true
}
func ExampleNewEncoder() {
enc := gojay.BorrowEncoder(os.Stdout)
var str = "gojay"
err := enc.EncodeString(str)
if err != nil {
log.Fatal(err)
}
// Output:
// "gojay"
}
func ExampleBorrowEncoder() {
enc := gojay.BorrowEncoder(os.Stdout)
defer enc.Release()
var str = "gojay"
err := enc.EncodeString(str)
if err != nil {
log.Fatal(err)
}
// Output:
// "gojay"
}
func ExampleEncoder_EncodeString() {
enc := gojay.BorrowEncoder(os.Stdout)
defer enc.Release()
var str = "gojay"
err := enc.EncodeString(str)
if err != nil {
log.Fatal(err)
}
// Output:
// "gojay"
}