Ensure decoder is set as well

Signed-off-by: Levi Gross <levi@levigross.com>
This commit is contained in:
Levi Gross
2017-11-26 18:47:04 -05:00
parent 4f31de8934
commit 56cec8d348
2 changed files with 17 additions and 4 deletions
+15 -2
View File
@@ -240,11 +240,25 @@ func (w *Writer) Float32(n float32) {
w.Buffer.Buf = strconv.AppendFloat(w.Buffer.Buf, float64(n), 'g', -1, 32)
}
func (w *Writer) Float32Str(n float32) {
w.Buffer.EnsureSpace(20)
w.Buffer.Buf = append(w.Buffer.Buf, '"')
w.Buffer.Buf = strconv.AppendFloat(w.Buffer.Buf, float64(n), 'g', -1, 32)
w.Buffer.Buf = append(w.Buffer.Buf, '"')
}
func (w *Writer) Float64(n float64) {
w.Buffer.EnsureSpace(20)
w.Buffer.Buf = strconv.AppendFloat(w.Buffer.Buf, n, 'g', -1, 64)
}
func (w *Writer) Float64Str(n float64) {
w.Buffer.EnsureSpace(20)
w.Buffer.Buf = append(w.Buffer.Buf, '"')
w.Buffer.Buf = strconv.AppendFloat(w.Buffer.Buf, float64(n), 'g', -1, 64)
w.Buffer.Buf = append(w.Buffer.Buf, '"')
}
func (w *Writer) Bool(v bool) {
w.Buffer.EnsureSpace(5)
if v {
@@ -340,12 +354,11 @@ func (w *Writer) base64(in []byte) {
return
}
w.Buffer.EnsureSpace(((len(in) - 1) / 3 + 1) * 4)
w.Buffer.EnsureSpace(((len(in)-1)/3 + 1) * 4)
si := 0
n := (len(in) / 3) * 3
for si < n {
// Convert 3x 8bit source bytes into 4 bytes
val := uint(in[si+0])<<16 | uint(in[si+1])<<8 | uint(in[si+2])
+2 -2
View File
@@ -38,8 +38,8 @@ type PrimitiveTypes struct {
Uint32String uint32 `json:",string"`
Uint64String uint64 `json:",string"`
Float32 float32 `json:", string"`
Float64 float64 `json:", string"`
Float32 float32 `json:",string"`
Float64 float64 `json:",string"`
Ptr *string
PtrNil *string