Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / honnef.co / go / tools@v0.0.1-2020.1.5 / staticcheck / testdata / src / CheckUnsupportedMarshal / CheckUnsupportedMarshal.go
1 package pkg
2
3 import (
4         "encoding/json"
5         "encoding/xml"
6 )
7
8 type T1 struct {
9         A int
10         B func() `json:"-" xml:"-"`
11         c chan int
12 }
13
14 type T2 struct {
15         T1
16 }
17
18 type T3 struct {
19         C chan int
20 }
21
22 type T4 struct {
23         C C
24 }
25
26 type T5 struct {
27         B func() `xml:"-"`
28 }
29
30 type T6 struct {
31         B func() `json:"-"`
32 }
33
34 type T7 struct {
35         A int
36         B int
37         T3
38 }
39
40 type T8 struct {
41         C int
42         *T7
43 }
44
45 type C chan int
46
47 func (C) MarshalText() ([]byte, error) { return nil, nil }
48
49 func fn() {
50         var t1 T1
51         var t2 T2
52         var t3 T3
53         var t4 T4
54         var t5 T5
55         var t6 T6
56         var t8 T8
57         json.Marshal(t1)
58         json.Marshal(t2)
59         json.Marshal(t3) // want `trying to marshal chan or func value, field CheckUnsupportedMarshal\.T3\.C`
60         json.Marshal(t4)
61         json.Marshal(t5) // want `trying to marshal chan or func value, field CheckUnsupportedMarshal\.T5\.B`
62         json.Marshal(t6)
63         (*json.Encoder)(nil).Encode(t1)
64         (*json.Encoder)(nil).Encode(t2)
65         (*json.Encoder)(nil).Encode(t3) // want `trying to marshal chan or func value, field CheckUnsupportedMarshal\.T3\.C`
66         (*json.Encoder)(nil).Encode(t4)
67         (*json.Encoder)(nil).Encode(t5) // want `trying to marshal chan or func value, field CheckUnsupportedMarshal\.T5\.B`
68         (*json.Encoder)(nil).Encode(t6)
69
70         xml.Marshal(t1)
71         xml.Marshal(t2)
72         xml.Marshal(t3) // want `trying to marshal chan or func value, field CheckUnsupportedMarshal\.T3\.C`
73         xml.Marshal(t4)
74         xml.Marshal(t5)
75         xml.Marshal(t6) // want `trying to marshal chan or func value, field CheckUnsupportedMarshal\.T6\.B`
76         (*xml.Encoder)(nil).Encode(t1)
77         (*xml.Encoder)(nil).Encode(t2)
78         (*xml.Encoder)(nil).Encode(t3) // want `trying to marshal chan or func value, field CheckUnsupportedMarshal\.T3\.C`
79         (*xml.Encoder)(nil).Encode(t4)
80         (*xml.Encoder)(nil).Encode(t5)
81         (*xml.Encoder)(nil).Encode(t6) // want `trying to marshal chan or func value, field CheckUnsupportedMarshal\.T6\.B`
82
83         json.Marshal(t8) // want `trying to marshal chan or func value, field CheckUnsupportedMarshal\.T8\.T7\.T3\.C`
84 }