use io.Writer

This commit is contained in:
Anton Evangelatov
2020-07-21 19:23:25 +02:00
parent 9154939d8f
commit 54f1f6b8c9
+4 -3
View File
@@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"html/template"
"io"
"os"
"reflect"
"sort"
@@ -874,7 +875,7 @@ var stateComputeStateCmd = &cli.Command{
return c.Code, nil
}
return ComputeStateHTMLTempl(ts, stout, getCode)
return ComputeStateHTMLTempl(os.Stdout, ts, stout, getCode)
}
fmt.Println("computed state cid: ", stout.Root)
@@ -1081,7 +1082,7 @@ type compStateHTMLIn struct {
Comp *api.ComputeStateOutput
}
func ComputeStateHTMLTempl(ts *types.TipSet, o *api.ComputeStateOutput, getCode func(addr address.Address) (cid.Cid, error)) error {
func ComputeStateHTMLTempl(w io.Writer, ts *types.TipSet, o *api.ComputeStateOutput, getCode func(addr address.Address) (cid.Cid, error)) error {
t, err := template.New("compute_state").Funcs(map[string]interface{}{
"GetCode": getCode,
"GetMethod": getMethod,
@@ -1114,7 +1115,7 @@ func ComputeStateHTMLTempl(ts *types.TipSet, o *api.ComputeStateOutput, getCode
return err
}
return t.ExecuteTemplate(os.Stdout, "compute_state", &compStateHTMLIn{
return t.ExecuteTemplate(w, "compute_state", &compStateHTMLIn{
TipSet: ts,
Comp: o,
})