• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang objects.HCID类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/AaronGoldman/ccfs/objects.HCID的典型用法代码示例。如果您正苦于以下问题:Golang HCID类的具体用法?Golang HCID怎么用?Golang HCID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了HCID类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: GetBlob

func (a appsscriptservice) GetBlob(h objects.HCID) (b objects.Blob, err error) {
	quarryurl := fmt.Sprintf(
		"%s%s%s%s%s%s",
		"https://",
		"script.google.com",
		"/macros/s/AKfycbzl2R7UR2FGGVdgl_WbKabbIoku66ELRSnQ4pbkmBgDdWWvgh8b/exec?",
		//"/macros/s/AKfycbxyU7ABEmq4HS_8nb7E5ZbtJKRwuVlLBwnhUJ4VjSH0/dev?",
		"type=blob",
		"&hcid=",
		h.Hex(),
	)
	//log.Println(quarryurl)
	resp, err := http.Get(quarryurl)
	if err != nil {
		return b, err
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return b, err
	}
	data, err := base64.StdEncoding.DecodeString(string(body))
	if err != nil {
		log.Printf("%s\n", body)
		log.Println("error:", err)
		return nil, err
	}
	return data, err
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:29,代码来源:appsscriptservice.go


示例2: GetBlob

func (k kademliaservice) GetBlob(h objects.HCID) (b objects.Blob, err error) {
	values := url.Values{}
	values.Add("type", "blob")
	values.Add("hcid", h.Hex())
	data, err := k.getobject(values)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return data, err
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:11,代码来源:kademliaservice.go


示例3: insertDescendant

func (indexEntry blobIndexEntry) insertDescendant(
	versionNumber int64,
	descendantHCID objects.HCID,
) blobIndexEntry {
	if indexEntry.Descendants == nil {
		indexEntry.Descendants = make(map[int64]string)
	}
	if _, present := indexEntry.Descendants[versionNumber]; !present {
		indexEntry.Descendants[versionNumber] = descendantHCID.Hex()
	}
	return indexEntry
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:12,代码来源:index.go


示例4: GetBlob

func (m multicastservice) GetBlob(h objects.HCID) (b objects.Blob, err error) {
	message := fmt.Sprintf("{\"type\":\"blob\", \"hcid\": \"%s\"}", h.Hex())
	blobchannel := make(chan objects.Blob, 1)
	m.waitingforblob[h.Hex()] = blobchannel
	m.sendmessage(message)
	select {
	case b = <-blobchannel:
		return b, err

	case <-time.After(150 * time.Millisecond):
		//log.Printf("Timing out now")
		return b, fmt.Errorf("GetBlob on Multicast service timed out")
	}
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:14,代码来源:multicastservice.go


示例5: GetBlob

func (gds googledriveservice) GetBlob(h objects.HCID) (objects.Blob, error) {

	if gds.driveService == nil {
		return nil, fmt.Errorf("Drive Service not initialized")
	}
	fileID, err := gds.getChildWithTitle(gds.blobsFolderID, h.Hex())
	f, err := gds.driveService.Files.Get(fileID).Do()
	fileString, err := gds.DownloadFile(f)
	if err != nil {
		log.Printf("An error occurred: %v\n", err)
		return nil, err
	}
	log.Printf("Blob %s:\n%q", h, fileString)
	return objects.Blob(fileString), err
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:15,代码来源:googledriveservice.go


示例6: GetBlob

func (d directhttpservice) GetBlob(h objects.HCID) (objects.Blob, error) {
	for _, host := range hosts {
		quarryurl := fmt.Sprintf(
			"https://%s/b/%s",
			host,
			h.Hex(),
		)
		body, err := urlReadAll(quarryurl)
		if err != nil {
			return objects.Blob{}, err
		}
		return objects.Blob(body), err
	}
	return objects.Blob{}, fmt.Errorf("No Hosts")
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:15,代码来源:directhttp.go


示例7: makeURL

func makeURL(hkid objects.HKID, hcid objects.HCID, typeString string, nameSegment string, version int64) (response string) {
	//Path
	if typeString == "blob" {
		response = fmt.Sprintf("/b/%s" /*host,*/, hcid.Hex())
	} else if typeString == "commit" {
		response = fmt.Sprintf("/c/%s/%d" /*host,*/, hkid.Hex(), version)
	} else if typeString == "tag" {
		response = fmt.Sprintf("/t/%s/%s/%d" /*host,*/, hkid.Hex(), nameSegment, version)
	} else if typeString == "key" {
		response = fmt.Sprintf("/k/%s" /*host,*/, hkid.Hex())
	} else {
		response = ""
	}
	return response
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:15,代码来源:checkAvailable.go


示例8: GetBlob

func (lfs localfileservice) GetBlob(h objects.HCID) (b objects.Blob, err error) {
	//ToDo Validate input
	if h == nil {
		return nil, fmt.Errorf("[localfileservice] GetBlob() HCID is nil")
	}
	filepath := fmt.Sprintf("bin/blobs/%s", h.Hex())
	//log.Printf("Filepath: %v", filepath)
	data, err := ioutil.ReadFile(filepath)
	if err != nil {
		//log.Printf("\n\t%v\n", err)
		return
	}
	//build object
	b = objects.Blob(data)
	return b, err
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:16,代码来源:localfileservice.go


示例9: buildResponse

func buildResponse(hkid objects.HKID, hcid objects.HCID, typeString string, nameSegment string, version int64) (response string) {
	if typeString == "blob" {
		response = fmt.Sprintf("{\"type\": \"blob\", \"hcid\": \"%s\", \"URL\": \"%s\"}", hcid.Hex(),
			makeURL(hkid, hcid, typeString, nameSegment, version))
	} else if typeString == "commit" {
		response = fmt.Sprintf("{\"type\": \"commit\",\"hkid\": \"%s\", \"URL\": \"%s\"}", hkid.Hex(),
			makeURL(hkid, hcid, typeString, nameSegment, version))
	} else if typeString == "tag" {
		response = fmt.Sprintf("{\"type\": \"tag\", \"hkid\": \"%s\", \"namesegment\": \"%s\", \"URL\": \"%s\"}", hkid.Hex(), nameSegment,
			makeURL(hkid, hcid, typeString, nameSegment, version))
	} else if typeString == "key" {
		response = fmt.Sprintf("{\"type\": \"key\",\"hkid\": \"%s\", \"URL\": \"%s\"}", hkid.Hex(),
			makeURL(hkid, hcid, typeString, nameSegment, version))
	} else {
		return ""
	}
	return response

}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:19,代码来源:checkAvailable.go



注:本文中的github.com/AaronGoldman/ccfs/objects.HCID类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang objects.HKID类代码示例发布时间:2022-05-24
下一篇:
Golang objects.HkidFromDString函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap