Skip to content

Commit 70033b7

Browse files
committed
cli/command/checkpoint: formatWrite: inline vars and use struct literals
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 8cb8056 commit 70033b7

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

cli/command/checkpoint/formatter.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,28 @@ func FormatWrite(fmtCtx formatter.Context, checkpoints []checkpoint.Summary) err
3434

3535
// formatWrite writes formatted checkpoints using the Context
3636
func formatWrite(fmtCtx formatter.Context, checkpoints []checkpoint.Summary) error {
37-
render := func(format func(subContext formatter.SubContext) error) error {
37+
cpContext := &checkpointContext{
38+
HeaderContext: formatter.HeaderContext{
39+
Header: formatter.SubHeaderContext{
40+
"Name": checkpointNameHeader,
41+
},
42+
},
43+
}
44+
return fmtCtx.Write(cpContext, func(format func(subContext formatter.SubContext) error) error {
3845
for _, cp := range checkpoints {
3946
if err := format(&checkpointContext{c: cp}); err != nil {
4047
return err
4148
}
4249
}
4350
return nil
44-
}
45-
return fmtCtx.Write(newCheckpointContext(), render)
51+
})
4652
}
4753

4854
type checkpointContext struct {
4955
formatter.HeaderContext
5056
c checkpoint.Summary
5157
}
5258

53-
func newCheckpointContext() *checkpointContext {
54-
cpCtx := checkpointContext{}
55-
cpCtx.Header = formatter.SubHeaderContext{
56-
"Name": checkpointNameHeader,
57-
}
58-
return &cpCtx
59-
}
60-
6159
func (c *checkpointContext) MarshalJSON() ([]byte, error) {
6260
return formatter.MarshalJSON(c)
6361
}

0 commit comments

Comments
 (0)