github.com/v2pro/plz@v0.0.0-20221028024117-e5f9aec5b631/msgfmt/formatter_json.go (about) 1 package msgfmt 2 3 import ( 4 "github.com/v2pro/plz/msgfmt/jsonfmt" 5 "github.com/v2pro/plz/reflect2" 6 ) 7 8 type jsonFormatter struct { 9 idx int 10 encoder jsonfmt.Encoder 11 } 12 13 func (formatter *jsonFormatter) Format(space []byte, kv []interface{}) []byte { 14 return formatter.encoder.Encode(nil, space, reflect2.PtrOf(kv[formatter.idx])) 15 }