本文整理汇总了Golang中camlistore/org/pkg/client.Client.GetPermanodesWithAttr方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.GetPermanodesWithAttr方法的具体用法?Golang Client.GetPermanodesWithAttr怎么用?Golang Client.GetPermanodesWithAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类camlistore/org/pkg/client.Client
的用法示例。
在下文中一共展示了Client.GetPermanodesWithAttr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
var conn *fuse.Conn
// Scans the arg list and sets up flags
client.AddFlags()
flag.Usage = usage
flag.Parse()
narg := flag.NArg()
if narg > 2 {
usage()
}
var mountPoint string
var err error
if narg > 0 {
mountPoint = flag.Arg(0)
} else {
mountPoint, err = ioutil.TempDir("", "cammount")
if err != nil {
log.Fatal(err)
}
log.Printf("No mount point given. Using: %s", mountPoint)
defer os.Remove(mountPoint)
}
errorf := func(msg string, args ...interface{}) {
fmt.Fprintf(os.Stderr, msg, args...)
fmt.Fprint(os.Stderr, "\n")
usage()
}
var (
cl *client.Client
root blob.Ref // nil if only one arg
camfs *fs.CamliFileSystem
)
if narg == 2 {
rootArg := flag.Arg(1)
// not trying very hard since NewFromShareRoot will do it better with a regex
if strings.HasPrefix(rootArg, "http://") ||
strings.HasPrefix(rootArg, "https://") {
if client.ExplicitServer() != "" {
errorf("Can't use an explicit blobserver with a share URL; the blobserver is implicit from the share URL.")
}
var err error
cl, root, err = client.NewFromShareRoot(rootArg)
if err != nil {
log.Fatal(err)
}
} else {
cl = client.NewOrFail() // automatic from flags
cl.SetHTTPClient(&http.Client{Transport: cl.TransportForConfig(nil)})
var ok bool
root, ok = blob.Parse(rootArg)
if !ok {
// not a blobref, check for root name instead
req := &search.WithAttrRequest{N: 1, Attr: "camliRoot", Value: rootArg}
wres, err := cl.GetPermanodesWithAttr(req)
if err != nil {
log.Fatal("could not query search")
}
if wres.WithAttr != nil {
root = wres.WithAttr[0].Permanode
} else {
log.Fatalf("root specified is not a blobref or name of a root: %q\n", rootArg)
}
}
}
} else {
cl = client.NewOrFail() // automatic from flags
cl.SetHTTPClient(&http.Client{Transport: cl.TransportForConfig(nil)})
}
diskCacheFetcher, err := cacher.NewDiskCache(cl)
if err != nil {
log.Fatalf("Error setting up local disk cache: %v", err)
}
defer diskCacheFetcher.Clean()
if root.Valid() {
var err error
camfs, err = fs.NewRootedCamliFileSystem(cl, diskCacheFetcher, root)
if err != nil {
log.Fatalf("Error creating root with %v: %v", root, err)
}
} else {
camfs = fs.NewDefaultCamliFileSystem(cl, diskCacheFetcher)
}
if *debug {
fuse.Debugf = log.Printf
// TODO: set fs's logger
}
// This doesn't appear to work on OS X:
sigc := make(chan os.Signal, 1)
//.........这里部分代码省略.........