1package test 2 3import "io" 4 5func init() { 6 var pCloser1 = func(str string) *io.Closer { 7 closer := io.Closer(strCloser1(str)) 8 return &closer 9 } 10 var pCloser2 = func(str string) *io.Closer { 11 strCloser := strCloser2(str) 12 closer := io.Closer(&strCloser) 13 return &closer 14 } 15 marshalCases = append(marshalCases, 16 pCloser1("hello"), 17 pCloser2("hello"), 18 ) 19 unmarshalCases = append(unmarshalCases, unmarshalCase{ 20 ptr: (*[]io.Closer)(nil), 21 input: "[null]", 22 }, unmarshalCase{ 23 obj: func() interface{} { 24 strCloser := strCloser2("") 25 return &struct { 26 Field io.Closer 27 }{ 28 &strCloser, 29 } 30 }, 31 input: `{"Field": "hello"}`, 32 }) 33} 34 35type strCloser1 string 36 37func (closer strCloser1) Close() error { 38 return nil 39} 40 41type strCloser2 string 42 43func (closer *strCloser2) Close() error { 44 return nil 45} 46