github.com/zignig/go-ipfs@v0.0.0-20141111235910-c9e5fdf55a52/core/commands/resolve.go (about) 1 package commands 2 3 import ( 4 "errors" 5 "fmt" 6 "io" 7 8 "github.com/jbenet/go-ipfs/core" 9 ) 10 11 func Resolve(n *core.IpfsNode, args []string, opts map[string]interface{}, out io.Writer) error { 12 13 name := "" 14 15 switch len(args) { 16 case 1: 17 name = args[0] 18 case 0: 19 if n.Identity == nil { 20 return errors.New("Identity not loaded!") 21 } 22 name = n.Identity.ID().String() 23 24 default: 25 return fmt.Errorf("Publish expects 1 or 2 args; got %d.", len(args)) 26 } 27 28 res, err := n.Namesys.Resolve(name) 29 if err != nil { 30 return err 31 } 32 33 fmt.Fprintf(out, "%s\n", res) 34 return nil 35 }