Commit 68870d03 authored by rht's avatar rht Committed by Jeromy

strings.Split -> path.SplitList

License: MIT
Signed-off-by: default avatarrht <rhtbot@gmail.com>
parent ef322f3c
...@@ -2,7 +2,6 @@ package dagutils ...@@ -2,7 +2,6 @@ package dagutils
import ( import (
"errors" "errors"
"strings"
ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore" ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync" syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
...@@ -12,6 +11,7 @@ import ( ...@@ -12,6 +11,7 @@ import (
bserv "github.com/ipfs/go-ipfs/blockservice" bserv "github.com/ipfs/go-ipfs/blockservice"
offline "github.com/ipfs/go-ipfs/exchange/offline" offline "github.com/ipfs/go-ipfs/exchange/offline"
dag "github.com/ipfs/go-ipfs/merkledag" dag "github.com/ipfs/go-ipfs/merkledag"
path "github.com/ipfs/go-ipfs/path"
) )
type Editor struct { type Editor struct {
...@@ -76,8 +76,8 @@ func addLink(ctx context.Context, ds dag.DAGService, root *dag.Node, childname s ...@@ -76,8 +76,8 @@ func addLink(ctx context.Context, ds dag.DAGService, root *dag.Node, childname s
return root, nil return root, nil
} }
func (e *Editor) InsertNodeAtPath(ctx context.Context, path string, toinsert *dag.Node, create func() *dag.Node) error { func (e *Editor) InsertNodeAtPath(ctx context.Context, pth string, toinsert *dag.Node, create func() *dag.Node) error {
splpath := strings.Split(path, "/") splpath := path.SplitList(pth)
nd, err := e.insertNodeAtPath(ctx, e.root, splpath, toinsert, create) nd, err := e.insertNodeAtPath(ctx, e.root, splpath, toinsert, create)
if err != nil { if err != nil {
return err return err
...@@ -130,8 +130,8 @@ func (e *Editor) insertNodeAtPath(ctx context.Context, root *dag.Node, path []st ...@@ -130,8 +130,8 @@ func (e *Editor) insertNodeAtPath(ctx context.Context, root *dag.Node, path []st
return root, nil return root, nil
} }
func (e *Editor) RmLink(ctx context.Context, path string) error { func (e *Editor) RmLink(ctx context.Context, pth string) error {
splpath := strings.Split(path, "/") splpath := path.SplitList(pth)
nd, err := e.rmLink(ctx, e.root, splpath) nd, err := e.rmLink(ctx, e.root, splpath)
if err != nil { if err != nil {
return err return err
......
package dagutils package dagutils
import ( import (
"strings"
"testing" "testing"
key "github.com/ipfs/go-ipfs/blocks/key" key "github.com/ipfs/go-ipfs/blocks/key"
dag "github.com/ipfs/go-ipfs/merkledag" dag "github.com/ipfs/go-ipfs/merkledag"
mdtest "github.com/ipfs/go-ipfs/merkledag/test" mdtest "github.com/ipfs/go-ipfs/merkledag/test"
path "github.com/ipfs/go-ipfs/path"
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
) )
...@@ -43,8 +43,8 @@ func TestAddLink(t *testing.T) { ...@@ -43,8 +43,8 @@ func TestAddLink(t *testing.T) {
} }
} }
func assertNodeAtPath(t *testing.T, ds dag.DAGService, root *dag.Node, path string, exp key.Key) { func assertNodeAtPath(t *testing.T, ds dag.DAGService, root *dag.Node, pth string, exp key.Key) {
parts := strings.Split(path, "/") parts := path.SplitList(pth)
cur := root cur := root
for _, e := range parts { for _, e := range parts {
nxt, err := cur.GetLinkedNode(context.Background(), ds, e) nxt, err := cur.GetLinkedNode(context.Background(), ds, e)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment