From fea0cda19db99a2686956f90994a49f619af5a30 Mon Sep 17 00:00:00 2001 From: Overbool Date: Tue, 6 Nov 2018 10:18:25 +0800 Subject: [PATCH] cmds: use w.Write directly License: MIT Signed-off-by: Overbool --- core/commands/config.go | 13 +++++++++---- core/commands/mount_unix.go | 6 ++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/core/commands/config.go b/core/commands/config.go index 0bd957004400..f4666a09cced 100644 --- a/core/commands/config.go +++ b/core/commands/config.go @@ -17,7 +17,7 @@ import ( "gx/ipfs/QmP2i47tnU23ijdshrZtuvrSkQPtf9HhsMb9fwGVe8owj2/jsondiff" cmds "gx/ipfs/Qma6uuSyjkecGhMFFLfzyJDPyoDtNJSHJNweDccZhaWkgU/go-ipfs-cmds" config "gx/ipfs/QmbK4EmM2Xx5fmbqK38TGP3PpY66r3tkXLZTcc7dF9mFwM/go-ipfs-config" - "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) // ConfigUpdateOutput is config profile apply command's output @@ -128,7 +128,9 @@ Set the value of the 'Datastore.Path' key: if err != nil { return err } - fmt.Fprintln(w, string(buf)) + buf = append(buf, byte('\n')) + + w.Write(buf) return nil }), }, @@ -175,7 +177,9 @@ NOTE: For security reasons, this command will omit your private key. If you woul if err != nil { return err } - fmt.Fprintln(w, string(buf)) + buf = append(buf, byte('\n')) + w.Write(buf) + return nil }), }, @@ -329,7 +333,8 @@ var configProfileApplyCmd = &cmds.Command{ diff := jsondiff.Compare(out.OldCfg, out.NewCfg) buf := jsondiff.Format(diff) - fmt.Fprint(w, string(buf)) + w.Write(buf) + return nil }), }, diff --git a/core/commands/mount_unix.go b/core/commands/mount_unix.go index 64e3d3de68f5..1568aa112d54 100644 --- a/core/commands/mount_unix.go +++ b/core/commands/mount_unix.go @@ -93,7 +93,7 @@ baz // error if we aren't running node in online mode if nd.LocalMode() { - return err + return ErrNotOnline } fsdir, found := req.Options[mountIPFSPathOptionName].(string) @@ -120,9 +120,7 @@ baz Type: config.Mounts{}, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, mounts *config.Mounts) error { - s := fmt.Sprintf("IPFS mounted at: %s\n", mounts.IPFS) - s += fmt.Sprintf("IPNS mounted at: %s\n", mounts.IPNS) - fmt.Fprint(w, s) + fmt.Fprintf(w, "IPFS mounted at: %s\nIPNS mounted at: %s\n", mounts.IPFS, mounts.IPNS) return nil }), },