mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-22 16:36:27 +01:00
5b7e8d1309
* lib/backup/s3remote: update AWS SDK to v2 * Update lib/backup/s3remote/s3.go Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com> * lib/backup/s3remote: refactor error handling Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
31 lines
594 B
Go
31 lines
594 B
Go
package json
|
|
|
|
import (
|
|
"bytes"
|
|
)
|
|
|
|
// Encoder is JSON encoder that supports construction of JSON values
|
|
// using methods.
|
|
type Encoder struct {
|
|
w *bytes.Buffer
|
|
Value
|
|
}
|
|
|
|
// NewEncoder returns a new JSON encoder
|
|
func NewEncoder() *Encoder {
|
|
writer := bytes.NewBuffer(nil)
|
|
scratch := make([]byte, 64)
|
|
|
|
return &Encoder{w: writer, Value: newValue(writer, &scratch)}
|
|
}
|
|
|
|
// String returns the String output of the JSON encoder
|
|
func (e Encoder) String() string {
|
|
return e.w.String()
|
|
}
|
|
|
|
// Bytes returns the []byte slice of the JSON encoder
|
|
func (e Encoder) Bytes() []byte {
|
|
return e.w.Bytes()
|
|
}
|