當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Client.GetPartial方法代碼示例

本文整理匯總了Golang中hyperdex/client.Client.GetPartial方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.GetPartial方法的具體用法?Golang Client.GetPartial怎麽用?Golang Client.GetPartial使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在hyperdex/client.Client的用法示例。


在下文中一共展示了Client.GetPartial方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: main

func main() {
	var attrs client.Attributes
	var objs chan client.Attributes
	var errs chan client.Error
	_ = attrs
	_ = objs
	_ = errs
	var c *client.Client
	var err client.Error
	port, _ := strconv.Atoi(os.Args[2])
	c, er, _ := client.NewClient(os.Args[1], port)
	if er != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	attrs, err = c.Get("kv", "k")
	if err.Status != client.NOTFOUND {
		fmt.Printf("bad status: %d (should be NOTFOUND)\n", err)
	}
	err = c.Put("kv", "k", client.Attributes{"v1": "ABC"})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	attrs, err = c.Get("kv", "k")
	if err.Status != client.SUCCESS {
		fmt.Printf("bad status: %d (should be SUCCESS)\n", err.Status)
	}
	if !sloppyEqualAttributes(attrs, client.Attributes{"v1": "ABC", "v2": ""}) {
		fmt.Printf("%s %s\n", attrs, client.Map{"v1": "ABC", "v2": ""})
		panic("objects not equal")
	}
	err = c.Put("kv", "k", client.Attributes{"v2": "123"})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	attrs, err = c.Get("kv", "k")
	if err.Status != client.SUCCESS {
		fmt.Printf("bad status: %d (should be SUCCESS)\n", err.Status)
	}
	if !sloppyEqualAttributes(attrs, client.Attributes{"v1": "ABC", "v2": "123"}) {
		fmt.Printf("%s %s\n", attrs, client.Map{"v1": "ABC", "v2": "123"})
		panic("objects not equal")
	}
	attrs, err = c.GetPartial("kv", "k", []string{"v1"})
	if err.Status != client.SUCCESS {
		fmt.Printf("bad status: %d (should be SUCCESS)\n", err.Status)
	}
	if !sloppyEqualAttributes(attrs, client.Attributes{"v1": "ABC"}) {
		fmt.Printf("%s %s\n", attrs, client.Map{"v1": "ABC"})
		panic("objects not equal")
	}
	os.Exit(0)
}
開發者ID:botvs,項目名稱:HyperDex,代碼行數:53,代碼來源:MultiAttribute.go


注:本文中的hyperdex/client.Client.GetPartial方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。