ls: make sure current builder is available in JSON output
While lsBuilder has a field called Current that gets lost because the embedded struct implements custom MarshalJSON method. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
+11
-1
@@ -213,7 +213,17 @@ type lsContext struct {
|
||||
}
|
||||
|
||||
func (c *lsContext) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.Builder)
|
||||
// can't marshal c.Builder directly because Builder type has custom MarshalJSON
|
||||
dt, err := json.Marshal(c.Builder.Builder)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var m map[string]any
|
||||
if err := json.Unmarshal(dt, &m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m["Current"] = c.Builder.Current
|
||||
return json.Marshal(m)
|
||||
}
|
||||
|
||||
func (c *lsContext) Name() string {
|
||||
|
||||
Reference in New Issue
Block a user