Debian Codegraph @

_test/issue-1010.go

raw symbols SCIP
1 package main
2
3 import (
4 "encoding/json"
5 "fmt"
6 )
7
8 type MyJsonMarshaler struct{ n int }
9
10 func (m MyJsonMarshaler) MarshalJSON() ([]byte, error) {
11 return []byte(fmt.Sprintf(`{"num": %d}`, m.n)), nil
12 }
13
14 func main() {
15 ch := make(chan json.Marshaler, 1)
16 ch <- MyJsonMarshaler{2}
17 m, err := json.Marshal(<-ch)
18 fmt.Println(string(m), err)
19 }
20
21 // Output:
22 // {"num":2} <nil>