1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-24 23:16:47 +02:00

fix build; add document for exported symbols

This commit is contained in:
Tao Wen
2017-07-09 14:48:34 +08:00
parent d3448d3dbd
commit bede1d7f40
16 changed files with 277 additions and 273 deletions

View File

@ -46,7 +46,7 @@ func (m *marshalerForTest) UnmarshalJSON(text []byte) error {
return nil
}
var _ json.Marshaler = Marshaler{}
var _ json.Unmarshaler = &Marshaler{}
var _ json.Marshaler = marshalerForTest{}
var _ json.Unmarshaler = &marshalerForTest{}
type typeForTest marshalerForTest

View File

@ -46,11 +46,11 @@ func (m *marshalerForTest) UnmarshalJSON(text []byte) error {
return nil
}
var _ json.Marshaler = Marshaler{}
var _ json.Unmarshaler = &Marshaler{}
var _ json.Marshaler = marshalerForTest{}
var _ json.Unmarshaler = &marshalerForTest{}
type typeForTest struct {
S string
M Marshaler
M marshalerForTest
I int8
}

View File

@ -7,7 +7,8 @@ import (
"strings"
)
type marshalerForTest string
// MarshalerForTest TEST ONLY
type MarshalerForTest string
func encode(str string) string {
buf := bytes.Buffer{}
@ -35,20 +36,20 @@ func decode(str string) string {
return string(bs)
}
func (m marshalerForTest) MarshalJSON() ([]byte, error) {
func (m MarshalerForTest) MarshalJSON() ([]byte, error) {
return []byte(`"MANUAL__` + encode(string(m)) + `"`), nil
}
func (m *marshalerForTest) UnmarshalJSON(text []byte) error {
*m = marshalerForTest(decode(strings.TrimPrefix(strings.Trim(string(text), `"`), "MANUAL__")))
func (m *MarshalerForTest) UnmarshalJSON(text []byte) error {
*m = MarshalerForTest(decode(strings.TrimPrefix(strings.Trim(string(text), `"`), "MANUAL__")))
return nil
}
var _ json.Marshaler = *new(marshalerForTest)
var _ json.Unmarshaler = new(marshalerForTest)
var _ json.Marshaler = *new(MarshalerForTest)
var _ json.Unmarshaler = new(MarshalerForTest)
type typeForTest struct {
F1 float64
Marshaler
MarshalerForTest
F2 int32
}

View File

@ -7,7 +7,8 @@ import (
"strings"
)
type marshalerForTest string
// MarshalerForTest TEST ONLY
type MarshalerForTest string
func encode(str string) string {
buf := bytes.Buffer{}
@ -35,20 +36,20 @@ func decode(str string) string {
return string(bs)
}
func (m marshalerForTest) MarshalText() ([]byte, error) {
func (m MarshalerForTest) MarshalText() ([]byte, error) {
return []byte(`MANUAL__` + encode(string(m))), nil
}
func (m *marshalerForTest) UnmarshalText(text []byte) error {
*m = marshalerForTest(decode(strings.TrimPrefix(string(text), "MANUAL__")))
func (m *MarshalerForTest) UnmarshalText(text []byte) error {
*m = MarshalerForTest(decode(strings.TrimPrefix(string(text), "MANUAL__")))
return nil
}
var _ encoding.TextMarshaler = *new(marshalerForTest)
var _ encoding.TextUnmarshaler = new(marshalerForTest)
var _ encoding.TextMarshaler = *new(MarshalerForTest)
var _ encoding.TextUnmarshaler = new(MarshalerForTest)
type typeForTest struct {
F1 float64
Marshaler
MarshalerForTest
F2 int32
}