diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-01 22:43:58 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-01 22:43:58 -0700 |
commit | d675f41242c043ddc4c6c1a1fb8aabcfd324aae2 (patch) | |
tree | 4f2afbce761eb377ad0b0ab2e4fb2f478ff844f5 /cmd/btrfs-rec/inspect_rebuildnodes.go | |
parent | 9971e38110d5f90d15c7b78f396f2638b3952a96 (diff) | |
parent | 6e1a9fbb1e9a943e04902ed3a4958f6821e39456 (diff) |
Merge branch 'lukeshu/lint'
Diffstat (limited to 'cmd/btrfs-rec/inspect_rebuildnodes.go')
-rw-r--r-- | cmd/btrfs-rec/inspect_rebuildnodes.go | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/cmd/btrfs-rec/inspect_rebuildnodes.go b/cmd/btrfs-rec/inspect_rebuildnodes.go index 0f3d60e..e61e6d2 100644 --- a/cmd/btrfs-rec/inspect_rebuildnodes.go +++ b/cmd/btrfs-rec/inspect_rebuildnodes.go @@ -1,12 +1,10 @@ -// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com> +// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com> // // SPDX-License-Identifier: GPL-2.0-or-later package main import ( - "bufio" - "io" "os" "git.lukeshu.com/go/lowmemjson" @@ -15,11 +13,8 @@ import ( "github.com/spf13/cobra" "git.lukeshu.com/btrfs-progs-ng/lib/btrfs" - "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsprim" - "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol" "git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsinspect" "git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsinspect/rebuildnodes" - "git.lukeshu.com/btrfs-progs-ng/lib/containers" ) func init() { @@ -44,7 +39,10 @@ func init() { } dlog.Info(ctx, "Writing re-built nodes to stdout...") - if err := writeNodesJSON(os.Stdout, rebuiltNodes); err != nil { + if err := writeJSONFile(os.Stdout, rebuiltNodes, lowmemjson.ReEncoder{ + Indent: "\t", + ForceTrailingNewlines: true, + }); err != nil { return err } dlog.Info(ctx, "... done writing") @@ -53,18 +51,3 @@ func init() { }, }) } - -func writeNodesJSON(w io.Writer, rebuiltNodes map[btrfsprim.ObjID]containers.Set[btrfsvol.LogicalAddr]) (err error) { - buffer := bufio.NewWriter(w) - defer func() { - if _err := buffer.Flush(); err == nil && _err != nil { - err = _err - } - }() - return lowmemjson.Encode(&lowmemjson.ReEncoder{ - Out: buffer, - - Indent: "\t", - ForceTrailingNewlines: true, - }, rebuiltNodes) -} |