From 47c87a66aa878147c2713f2e7e234ee4a4bd64ed Mon Sep 17 00:00:00 2001 From: Overbool Date: Sat, 27 Oct 2018 13:54:49 +0800 Subject: [PATCH] commands: use io.Writer in tabwriter License: MIT Signed-off-by: Overbool --- core/commands/active.go | 9 ++------- core/commands/config.go | 2 +- core/commands/diag.go | 2 +- core/commands/log.go | 2 +- core/commands/mount_nofuse.go | 2 +- core/commands/mount_unix.go | 2 +- core/commands/mount_windows.go | 2 +- core/commands/root.go | 2 +- core/commands/sysdiag.go | 2 +- 9 files changed, 10 insertions(+), 15 deletions(-) diff --git a/core/commands/active.go b/core/commands/active.go index 4fada6f1398f..21e4b9c32bc4 100644 --- a/core/commands/active.go +++ b/core/commands/active.go @@ -1,7 +1,6 @@ package commands import ( - "bytes" "fmt" "io" "sort" @@ -10,7 +9,7 @@ import ( oldcmds "github.com/ipfs/go-ipfs/commands" - cmds "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds" + cmds "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) @@ -40,9 +39,7 @@ Lists running and recently run commands. cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *[]*cmds.ReqLogEntry) error { verbose, _ := req.Options[verboseOptionName].(bool) - buf := new(bytes.Buffer) - - tw := tabwriter.NewWriter(buf, 4, 4, 2, ' ', 0) + tw := tabwriter.NewWriter(w, 4, 4, 2, ' ', 0) if verbose { fmt.Fprint(tw, "ID\t") } @@ -82,8 +79,6 @@ Lists running and recently run commands. } tw.Flush() - fmt.Fprint(w, buf) - return nil }), }, diff --git a/core/commands/config.go b/core/commands/config.go index 30d1bb82acce..8e8c690b745b 100644 --- a/core/commands/config.go +++ b/core/commands/config.go @@ -16,7 +16,7 @@ import ( "gx/ipfs/QmP2i47tnU23ijdshrZtuvrSkQPtf9HhsMb9fwGVe8owj2/jsondiff" config "gx/ipfs/QmPEpj17FDRpc7K1aArKZp3RsHtzRMKykeK9GVgn4WQGPR/go-ipfs-config" - cmds "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds" + cmds "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/diag.go b/core/commands/diag.go index b456b1f08432..6b9a44ec8a86 100644 --- a/core/commands/diag.go +++ b/core/commands/diag.go @@ -1,7 +1,7 @@ package commands import ( - cmds "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds" + cmds "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/log.go b/core/commands/log.go index 47c1c7a3aee6..49e24056c780 100644 --- a/core/commands/log.go +++ b/core/commands/log.go @@ -4,9 +4,9 @@ import ( "fmt" "io" + cmds "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds" logging "gx/ipfs/QmZChCsSt8DctjceaL56Eibc29CVQq4dGKRXC5JRZ6Ppae/go-log" lwriter "gx/ipfs/QmZChCsSt8DctjceaL56Eibc29CVQq4dGKRXC5JRZ6Ppae/go-log/writer" - cmds "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/mount_nofuse.go b/core/commands/mount_nofuse.go index db31b91d78f7..cd93ac319b25 100644 --- a/core/commands/mount_nofuse.go +++ b/core/commands/mount_nofuse.go @@ -3,7 +3,7 @@ package commands import ( - cmds "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds" + cmds "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/mount_unix.go b/core/commands/mount_unix.go index ef19861dfe38..64c35bca050a 100644 --- a/core/commands/mount_unix.go +++ b/core/commands/mount_unix.go @@ -10,7 +10,7 @@ import ( nodeMount "github.com/ipfs/go-ipfs/fuse/node" config "gx/ipfs/QmPEpj17FDRpc7K1aArKZp3RsHtzRMKykeK9GVgn4WQGPR/go-ipfs-config" - cmds "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds" + cmds "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/mount_windows.go b/core/commands/mount_windows.go index 3f99e86e1306..07b1a42a8fbc 100644 --- a/core/commands/mount_windows.go +++ b/core/commands/mount_windows.go @@ -3,7 +3,7 @@ package commands import ( "errors" - cmds "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds" + cmds "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/root.go b/core/commands/root.go index ee62e8c522b2..b8a9e3477e08 100644 --- a/core/commands/root.go +++ b/core/commands/root.go @@ -15,7 +15,7 @@ import ( cmds "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds" logging "gx/ipfs/QmZChCsSt8DctjceaL56Eibc29CVQq4dGKRXC5JRZ6Ppae/go-log" - "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) var log = logging.Logger("core/commands") diff --git a/core/commands/sysdiag.go b/core/commands/sysdiag.go index 026cd1ed6e04..55bc5a43e4bc 100644 --- a/core/commands/sysdiag.go +++ b/core/commands/sysdiag.go @@ -8,9 +8,9 @@ import ( version "github.com/ipfs/go-ipfs" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" + cmds "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds" sysi "gx/ipfs/QmZRjKbHa6DenStpQJFiaPcEwkZqrx7TH6xTf342LDU3qM/go-sysinfo" manet "gx/ipfs/Qmaabb1tJZ2CX5cp6MuuiGgns71NYoxdgQP6Xdid1dVceC/go-multiaddr-net" - cmds "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" )