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


Golang objects.HKID类代码示例

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


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

示例1: GetCommit

func (gds googledriveservice) GetCommit(h objects.HKID) (c objects.Commit, err error) {
	if gds.driveService == nil {
		return objects.Commit{}, fmt.Errorf("Drive Service not initialized")
	}
	thisCommitFolderID, err := gds.getChildWithTitle(gds.commitsFolderID, h.Hex())
	r, err := gds.driveService.Children.List(thisCommitFolderID).Do()
	if err != nil {
		log.Printf("Error: %v\n", err)
		return
	}
	if len(r.Items) < 1 {
		return objects.Commit{}, fmt.Errorf("no file %s", h.Hex())
	}
	latestTitle := ""
	thisCommitfile := new(drive.File)
	for _, item := range r.Items {
		f, err := gds.driveService.Files.Get(item.Id).Do()
		if err != nil {
			return c, err
		}
		if f.Title > latestTitle && err == nil {
			latestTitle = f.Title
			thisCommitfile = f
		}
	}
	commitBytes, err := gds.DownloadFile(thisCommitfile)
	log.Printf("Commit %s:\n%q", h, commitBytes)
	c, err = objects.CommitFromBytes(commitBytes)
	return c, err
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:30,代码来源:googledriveservice.go

示例2: GetTag

func (a appsscriptservice) GetTag(h objects.HKID, namesegment string) (t objects.Tag, err error) {
	quarryurl := fmt.Sprintf(
		"%s%s%s%s%s%s%s",
		"https://",
		"script.google.com",
		"/macros/s/AKfycbzl2R7UR2FGGVdgl_WbKabbIoku66ELRSnQ4pbkmBgDdWWvgh8b/exec?",
		//"/macros/s/AKfycbxyU7ABEmq4HS_8nb7E5ZbtJKRwuVlLBwnhUJ4VjSH0/dev?",
		"type=tag&hkid=",
		h.Hex(),
		"&namesegment=",
		namesegment,
	)
	//log.Println(quarryurl)
	resp, err := http.Get(quarryurl)
	if err != nil {
		return t, err
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return t, err
	}
	data, err := base64.StdEncoding.DecodeString(string(body))
	if err != nil {
		log.Println("error:", err)
		return t, err
	}
	t, err = objects.TagFromBytes(data)
	return t, err
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:30,代码来源:appsscriptservice.go

示例3: GetTag

func (d directhttpservice) GetTag(h objects.HKID, namesegment string) (
	objects.Tag, error) {
	for _, host := range hosts {
		quarryurl := fmt.Sprintf(
			"https://%s/t/%s/%s",
			host,
			h.Hex(),
			namesegment,
		)
		bodyVersions, err := urlReadAll(quarryurl)
		if err != nil {
			return objects.Tag{}, err
		}
		versionNumber := latestsVersion(bodyVersions)
		tagurl := fmt.Sprintf(
			"https://%s/t/%s/%s/%s",
			host,
			h.Hex(),
			namesegment,
			versionNumber,
		)
		body, err := urlReadAll(tagurl)
		tag, err := objects.TagFromBytes(body)
		if err == nil {
			return tag, err
		}
	}
	return objects.Tag{}, fmt.Errorf("No Hosts")
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:29,代码来源:directhttp.go

示例4: GetKey

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

示例5: GetCommit

func (d directhttpservice) GetCommit(h objects.HKID) (objects.Commit, error) {
	for _, host := range hosts {
		urlVersions := fmt.Sprintf(
			"https://%s/c/%s/",
			host,
			h.Hex(),
		)
		bodyVersions, errVersions := urlReadAll(urlVersions)
		if errVersions != nil {
			return objects.Commit{}, errVersions
		}
		versionNumber := latestsVersion(bodyVersions)
		urlCommit := fmt.Sprintf(
			"https://%s/c/%s/%s",
			host,
			h.Hex(),
			versionNumber,
		)
		body, err := urlReadAll(urlCommit)
		if err != nil {
			return objects.Commit{}, err
		}
		commit, err := objects.CommitFromBytes(body)
		if err == nil {
			return commit, err
		}
	}
	return objects.Commit{}, fmt.Errorf("No Hosts")
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:29,代码来源:directhttp.go

示例6: GetTags

func (lfs localfileservice) GetTags(h objects.HKID) (tags []objects.Tag, err error) {
	//ToDo Validate input
	directoryEntries, err := ioutil.ReadDir(fmt.Sprintf("bin/tags/%s", h.Hex()))
	if err != nil {
		log.Println(err)
	}
	//log.Println(h)
	namesegment := ""
	for _, directoryEntry := range directoryEntries {
		if directoryEntry.IsDir() {
			namesegment = directoryEntry.Name()
		} else {
			continue
		}
		matches, err := filepath.Glob(fmt.Sprintf("bin/tags/%s/%s/*",
			h.Hex(), namesegment))
		filepath := lfs.latestVersion(matches)
		//log.Printf("Filepath: %v", filepath)
		data, err := ioutil.ReadFile(filepath)
		if err == nil {
			tag, err := objects.TagFromBytes(data)
			if err == nil {
				tags = append(tags, tag)
			} else {
				log.Println(err)
			}
		} else {
			log.Panicln(err)
		}
	}
	//log.Println(tags)
	return tags, err
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:33,代码来源:localfileservice.go

示例7: GetTag

func (gds googledriveservice) GetTag(h objects.HKID, namesegment string) (t objects.Tag, err error) {
	if gds.driveService == nil {
		return objects.Tag{}, fmt.Errorf("Drive Service not initialized")
	}
	hkidTagFolderID, err := gds.getChildWithTitle(gds.tagsFolderID, h.Hex())
	nameSegmentTagFolderID, err := gds.getChildWithTitle(hkidTagFolderID, namesegment)
	r, err := gds.driveService.Children.List(nameSegmentTagFolderID).Do()
	if err != nil {
		log.Printf("Error: %v\n", err)
		return objects.Tag{}, err
	}
	if len(r.Items) < 1 {
		return objects.Tag{}, fmt.Errorf("no file %s ,%s", h.Hex(), namesegment)
	}
	latestTitle := ""
	thisTagfile := new(drive.File)
	for _, item := range r.Items {
		f, err := gds.driveService.Files.Get(item.Id).Do()
		if err != nil {
			return t, err
		} //log.Println(f.Title)
		if f.Title > latestTitle && err == nil {
			latestTitle = f.Title
			thisTagfile = f
		}

	}
	tagBytes, err := gds.DownloadFile(thisTagfile)
	log.Printf("Tag %s:\n%q", h, tagBytes)
	t, err = objects.TagFromBytes(tagBytes)
	return t, nil
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:32,代码来源:googledriveservice.go

示例8: composeQuery

func composeQuery(typestring string, hash objects.HKID, namesegment string) (message string) {
	message = fmt.Sprintf("%s,%s", typestring, hash.String())
	if namesegment != "" {
		message = fmt.Sprintf("%s,%s", message, namesegment)
	}
	return message

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

示例9: GetKey

func (lfs localfileservice) GetKey(h objects.HKID) (objects.Blob, error) {
	filepath := fmt.Sprintf("bin/keys/%s", h.Hex())
	//log.Printf("Filepath: %v", filepath)
	filedata, err := ioutil.ReadFile(filepath)
	if err != nil {
		log.Println(err)
	}
	return filedata, err
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:9,代码来源:localfileservice.go

示例10: GetKey

func (k kademliaservice) GetKey(h objects.HKID) (b objects.Blob, err error) {
	values := url.Values{}
	values.Add("type", "key")
	values.Add("hkid", 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

示例11: GetCommit

func (k kademliaservice) GetCommit(h objects.HKID) (c objects.Commit, err error) {
	values := url.Values{}
	values.Add("type", "commit")
	values.Add("hkid", h.Hex())
	data, err := k.getobject(values)
	if err != nil {
		log.Println(err)
		return c, err
	}
	c, err = objects.CommitFromBytes(data)
	return c, err
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:12,代码来源:kademliaservice.go

示例12: GetCommit

func (lfs localfileservice) GetCommit(h objects.HKID) (c objects.Commit, err error) {
	//Validate input
	matches, err := filepath.Glob(fmt.Sprintf("bin/commits/%s/*", h.Hex()))
	filepath := lfs.latestVersion(matches)
	//log.Printf("Filepath: %v", filepath)
	data, err := ioutil.ReadFile(filepath)
	if err != nil {
		return
	}
	c, err = objects.CommitFromBytes(data)
	return c, err
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:12,代码来源:localfileservice.go

示例13: GetTag

func (k kademliaservice) GetTag(h objects.HKID, namesegment string) (t objects.Tag, err error) {
	values := url.Values{}
	values.Add("type", "tag")
	values.Add("hkid", h.Hex())
	values.Add("namesegment", namesegment)
	data, err := k.getobject(values)
	if err != nil {
		log.Println(err)
		return t, err
	}
	t, err = objects.TagFromBytes(data)
	return t, err
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:13,代码来源:kademliaservice.go

示例14: GetKey

func (gds googledriveservice) GetKey(h objects.HKID) (b objects.Blob, err error) {
	if gds.driveService == nil {
		return nil, fmt.Errorf("Drive Service not initialized")
	}
	fileID, err := gds.getChildWithTitle(gds.keysFolderID, 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("Key %s:\n%q", h, fileString)
	return objects.Blob(fileString), err
}
开发者ID:AaronGoldman,项目名称:ccfs,代码行数:14,代码来源:googledriveservice.go

示例15: GetKey

func (m multicastservice) GetKey(h objects.HKID) (b objects.Blob, err error) {
	message := fmt.Sprintf("{\"type\":\"key\",\"hkid\": \"%s\"}", h.Hex())
	m.sendmessage(message)
	keychannel := make(chan objects.Blob)
	m.waitingforkey[h.Hex()] = keychannel
	select {
	case b = <-keychannel:
		return b, err

	case <-time.After(12000 * time.Millisecond):
		//log.Printf("Timing out now")
		return b, fmt.Errorf("GetKey on Multicast service timed out")
	}

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


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