@@ -41,17 +41,61 @@ func (enc *Encoder) encodeFloat32(n float32) ([]byte, error) {
4141
4242// AddFloat adds a float64 to be encoded, must be used inside a slice or array encoding (does not encode a key)
4343func (enc * Encoder ) AddFloat (v float64 ) {
44- enc .Float (v )
44+ enc .Float64 (v )
4545}
4646
4747// AddFloatOmitEmpty adds a float64 to be encoded and skips it if its value is 0,
4848// must be used inside a slice or array encoding (does not encode a key).
4949func (enc * Encoder ) AddFloatOmitEmpty (v float64 ) {
50- enc .FloatOmitEmpty (v )
50+ enc .Float64OmitEmpty (v )
5151}
5252
5353// Float adds a float64 to be encoded, must be used inside a slice or array encoding (does not encode a key)
5454func (enc * Encoder ) Float (v float64 ) {
55+ enc .Float64 (v )
56+ }
57+
58+ // FloatOmitEmpty adds a float64 to be encoded and skips it if its value is 0,
59+ // must be used inside a slice or array encoding (does not encode a key).
60+ func (enc * Encoder ) FloatOmitEmpty (v float64 ) {
61+ enc .Float64OmitEmpty (v )
62+ }
63+
64+ // AddFloatKey adds a float64 to be encoded, must be used inside an object as it will encode a key
65+ func (enc * Encoder ) AddFloatKey (key string , v float64 ) {
66+ enc .Float64Key (key , v )
67+ }
68+
69+ // AddFloatKeyOmitEmpty adds a float64 to be encoded and skips it if its value is 0.
70+ // Must be used inside an object as it will encode a key
71+ func (enc * Encoder ) AddFloatKeyOmitEmpty (key string , v float64 ) {
72+ enc .Float64KeyOmitEmpty (key , v )
73+ }
74+
75+ // FloatKey adds a float64 to be encoded, must be used inside an object as it will encode a key
76+ func (enc * Encoder ) FloatKey (key string , v float64 ) {
77+ enc .Float64Key (key , v )
78+ }
79+
80+ // FloatKeyOmitEmpty adds a float64 to be encoded and skips it if its value is 0.
81+ // Must be used inside an object as it will encode a key
82+ func (enc * Encoder ) FloatKeyOmitEmpty (key string , v float64 ) {
83+ enc .Float64KeyOmitEmpty (key , v )
84+ }
85+
86+ // AddFloat64 adds a float64 to be encoded, must be used inside a slice or array encoding (does not encode a key)
87+ func (enc * Encoder ) AddFloat64 (v float64 ) {
88+ enc .Float (v )
89+ }
90+
91+ // AddFloat64OmitEmpty adds a float64 to be encoded and skips it if its value is 0,
92+ // must be used inside a slice or array encoding (does not encode a key).
93+ func (enc * Encoder ) AddFloat64OmitEmpty (v float64 ) {
94+ enc .FloatOmitEmpty (v )
95+ }
96+
97+ // Float64 adds a float64 to be encoded, must be used inside a slice or array encoding (does not encode a key)
98+ func (enc * Encoder ) Float64 (v float64 ) {
5599 enc .grow (10 )
56100 r := enc .getPreviousRune ()
57101 if r != '[' {
@@ -60,9 +104,9 @@ func (enc *Encoder) Float(v float64) {
60104 enc .buf = strconv .AppendFloat (enc .buf , v , 'f' , - 1 , 64 )
61105}
62106
63- // FloatOmitEmpty adds a float64 to be encoded and skips it if its value is 0,
107+ // Float64OmitEmpty adds a float64 to be encoded and skips it if its value is 0,
64108// must be used inside a slice or array encoding (does not encode a key).
65- func (enc * Encoder ) FloatOmitEmpty (v float64 ) {
109+ func (enc * Encoder ) Float64OmitEmpty (v float64 ) {
66110 if v == 0 {
67111 return
68112 }
@@ -74,19 +118,19 @@ func (enc *Encoder) FloatOmitEmpty(v float64) {
74118 enc .buf = strconv .AppendFloat (enc .buf , v , 'f' , - 1 , 64 )
75119}
76120
77- // AddFloatKey adds a float64 to be encoded, must be used inside an object as it will encode a key
78- func (enc * Encoder ) AddFloatKey (key string , v float64 ) {
121+ // AddFloat64Key adds a float64 to be encoded, must be used inside an object as it will encode a key
122+ func (enc * Encoder ) AddFloat64Key (key string , v float64 ) {
79123 enc .FloatKey (key , v )
80124}
81125
82- // AddFloatKeyOmitEmpty adds a float64 to be encoded and skips it if its value is 0.
126+ // AddFloat64KeyOmitEmpty adds a float64 to be encoded and skips it if its value is 0.
83127// Must be used inside an object as it will encode a key
84- func (enc * Encoder ) AddFloatKeyOmitEmpty (key string , v float64 ) {
128+ func (enc * Encoder ) AddFloat64KeyOmitEmpty (key string , v float64 ) {
85129 enc .FloatKeyOmitEmpty (key , v )
86130}
87131
88- // FloatKey adds a float64 to be encoded, must be used inside an object as it will encode a key
89- func (enc * Encoder ) FloatKey (key string , value float64 ) {
132+ // Float64Key adds a float64 to be encoded, must be used inside an object as it will encode a key
133+ func (enc * Encoder ) Float64Key (key string , value float64 ) {
90134 r := enc .getPreviousRune ()
91135 if r != '{' {
92136 enc .writeByte (',' )
@@ -98,9 +142,9 @@ func (enc *Encoder) FloatKey(key string, value float64) {
98142 enc .buf = strconv .AppendFloat (enc .buf , value , 'f' , - 1 , 64 )
99143}
100144
101- // FloatKeyOmitEmpty adds a float64 to be encoded and skips it if its value is 0.
145+ // Float64KeyOmitEmpty adds a float64 to be encoded and skips it if its value is 0.
102146// Must be used inside an object as it will encode a key
103- func (enc * Encoder ) FloatKeyOmitEmpty (key string , v float64 ) {
147+ func (enc * Encoder ) Float64KeyOmitEmpty (key string , v float64 ) {
104148 if v == 0 {
105149 return
106150 }
0 commit comments