From 7b716986f67db2ab87223b6b39d3dad96cf14a7e Mon Sep 17 00:00:00 2001
From: Thomas Gardner <tmg@fastmail.com>
Date: Sun, 24 Jan 2016 10:34:13 +1000
Subject: [PATCH] Append newlines to `ipfs id` and `ipfs dns` output.

This fixes #1083, #2000.

N.B. The JSON package developers see no trailing newline as a feature;
it allows marshalled JSON to be embedded inside more JSON.[0]

--
[0] https://golang.org/pkg/encoding/json/

License: MIT
Signed-off-by: Thomas Gardner <tmg@fastmail.com>
---
 core/commands/dns.go | 2 +-
 core/commands/id.go  | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/core/commands/dns.go b/core/commands/dns.go
index 56bbd5637..ee10807c8 100644
--- a/core/commands/dns.go
+++ b/core/commands/dns.go
@@ -75,7 +75,7 @@ The resolver will give:
 			if !ok {
 				return nil, util.ErrCast()
 			}
-			return strings.NewReader(output.Path.String()), nil
+			return strings.NewReader(output.Path.String() + "\n"), nil
 		},
 	},
 	Type: ResolvedPath{},
diff --git a/core/commands/id.go b/core/commands/id.go
index 8de6cfa07..b492bf80b 100644
--- a/core/commands/id.go
+++ b/core/commands/id.go
@@ -133,6 +133,7 @@ ipfs id supports the format option for output with the following keys:
 				if err != nil {
 					return nil, err
 				}
+				marshaled = append(marshaled, byte('\n'))
 				return bytes.NewReader(marshaled), nil
 			}
 		},
-- 
GitLab