当前位置: 首页>>代码示例>>Golang>>正文


Golang HCID.Hex方法代码示例

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


在下文中一共展示了HCID.Hex方法的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.Hex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。