diff --git a/cmd/ipfs2/daemon.go b/cmd/ipfs2/daemon.go index 9ffe96d9d..da3603cad 100644 --- a/cmd/ipfs2/daemon.go +++ b/cmd/ipfs2/daemon.go @@ -9,7 +9,7 @@ import ( cmds "github.com/jbenet/go-ipfs/commands" cmdsHttp "github.com/jbenet/go-ipfs/commands/http" - "github.com/jbenet/go-ipfs/core" + core "github.com/jbenet/go-ipfs/core" commands "github.com/jbenet/go-ipfs/core/commands2" daemon "github.com/jbenet/go-ipfs/daemon2" ) diff --git a/core/commands2/add.go b/core/commands2/add.go index ccb5e86c1..ab22bf3c7 100644 --- a/core/commands2/add.go +++ b/core/commands2/add.go @@ -62,14 +62,18 @@ var addCmd = &cmds.Command{ }, Marshallers: map[cmds.EncodingType]cmds.Marshaller{ cmds.Text: func(res cmds.Response) ([]byte, error) { - v := res.Output().(*AddOutput).Added - if len(v) == 1 { - s := fmt.Sprintf("Added object: %s\n", v[0].Hash) + val, ok := res.Output().(*AddOutput) + if !ok { + return nil, errors.New("cast err") + } + added := val.Added + if len(added) == 1 { + s := fmt.Sprintf("Added object: %s\n", added[0].Hash) return []byte(s), nil } - s := fmt.Sprintf("Added %v objects:\n", len(v)) - for _, obj := range v { + s := fmt.Sprintf("Added %v objects:\n", len(added)) + for _, obj := range added { s += fmt.Sprintf("- %s\n", obj.Hash) } return []byte(s), nil