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

Golang com.Expand函数代码示例

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

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



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

示例1: msgWrite

func (as *ArticleService) msgWrite(isUpdate bool, article *model.Article) {
	data := map[string]string{
		"type":   fmt.Sprint(model.MESSAGE_TYPE_ARTICLE_CREATE),
		"author": article.User().Name,
		"link":   article.Href(),
		"title":  article.Title,
		"time":   utils.TimeUnixFormat(article.CreateTime, "01/02 15:04:05"),
	}
	var body string
	if isUpdate {
		data["type"] = fmt.Sprint(model.MESSAGE_TYPE_ARTICLE_UPDATE)
		data["time"] = utils.TimeUnixFormat(article.UpdateTime, "01/02 15:04:05")
		body = com.Expand(MessageArticleUpdateTemplate, data)
	} else {
		body = com.Expand(MessageArticleCreateTemplate, data)
	}
	message := &model.Message{
		UserId:     article.UserId,
		From:       model.MESSAGE_FROM_ARTICLE,
		FromId:     article.Id,
		Type:       model.MESSAGE_TYPE_ARTICLE_CREATE,
		Body:       body,
		CreateTime: article.CreateTime,
	}
	if isUpdate {
		message.Type = model.MESSAGE_TYPE_ARTICLE_UPDATE
	}
	Message.Save(message)
}
开发者ID:hxdyxd,项目名称:pugo,代码行数:29,代码来源:article.go


示例2: msgSave

func (cs *CommentService) msgSave(cmt *model.Comment) {
	data := map[string]string{
		"type":   fmt.Sprint(model.MESSAGE_TYPE_COMMENT_CREATE),
		"time":   utils.TimeUnixFormat(cmt.CreateTime, "01/02 15:04:05"),
		"author": cmt.Name,
		"site":   cmt.AuthorUrl(),
		"body":   cmt.Body,
		"title":  cmt.FromTitle(),
	}

	message := &model.Message{
		UserId:     cmt.UserId,
		From:       model.MESSAGE_FROM_COMMENT,
		FromId:     cmt.Id,
		Type:       model.MESSAGE_TYPE_COMMENT_CREATE,
		CreateTime: cmt.CreateTime,
	}

	if cmt.ParentId > 0 {
		if p := cmt.GetParent(); p != nil {
			data["parent"] = p.Name
			data["parent_content"] = p.Body
			fmt.Println("--------------", p)
			message.Type = model.MESSAGE_TYPE_COMMENT_REPLY
			message.Body = com.Expand(MessageCommentReplyTemplate, data)
			Message.Save(message)
			return
		}
	}
	message.Body = com.Expand(MessageCommentLeaveTemplate, data)
	Message.Save(message)
}
开发者ID:hxdyxd,项目名称:pugo,代码行数:32,代码来源:comment.go


示例3: getDynamic

func getDynamic(importPath, etag string) (pdoc *Package, err error) {
	match, err := fetchMeta(importPath)
	if err != nil {
		return nil, err
	}

	if match["projectRoot"] != importPath {
		rootMatch, err := fetchMeta(match["projectRoot"])
		if err != nil {
			return nil, err
		}
		if rootMatch["projectRoot"] != match["projectRoot"] {
			return nil, errors.New("Project root mismatch")
		}
	}

	pdoc, err = getStatic(com.Expand("{repo}{dir}", match), etag)
	// if err == ErrNoServiceMatch {
	// 	pdoc, err = getVCSDoc(client, match, etag)
	// }
	if err != nil {
		return nil, err
	}

	if pdoc != nil {
		pdoc.ImportPath = importPath
		pdoc.ProjectPath = importPath
		// pdoc.ProjectName = match["projectName"]
	}

	return pdoc, err
}
开发者ID:qiancy,项目名称:gowalker,代码行数:32,代码来源:crawl.go


示例4: earlyResponseForGoGetMeta

// earlyResponseForGoGetMeta responses appropriate go-get meta with status 200
// if user does not have actual access to the requested repository,
// or the owner or repository does not exist at all.
// This is particular a workaround for "go get" command which does not respect
// .netrc file.
func earlyResponseForGoGetMeta(ctx *Context) {
	ctx.PlainText(200, []byte(com.Expand(`<meta name="go-import" content="{GoGetImport} git {CloneLink}">`,
		map[string]string{
			"GoGetImport": composeGoGetImport(ctx.Params(":username"), ctx.Params(":reponame")),
			"CloneLink":   models.ComposeHTTPSCloneURL(ctx.Params(":username"), ctx.Params(":reponame")),
		})))
}
开发者ID:vroomanj,项目名称:gogs,代码行数:12,代码来源:repo.go


示例5: msgDelete

func (as *ArticleService) msgDelete(id int64) {
	article := new(model.Article)
	if _, err := core.Db.Where("id = ?", id).Get(article); err != nil {
		return
	}
	if article == nil || article.Id != id {
		return
	}
	data := map[string]string{
		"type":   fmt.Sprint(model.MESSAGE_TYPE_ARTICLE_REMOVE),
		"author": article.User().Name,
		"title":  article.Title,
		"time":   utils.TimeUnixFormat(article.CreateTime, "01/02 15:04:05"),
	}
	body := com.Expand(MessageArticleRemoveTemplate, data)
	message := &model.Message{
		UserId:     article.UserId,
		From:       model.MESSAGE_FROM_ARTICLE,
		FromId:     article.Id,
		Type:       model.MESSAGE_TYPE_ARTICLE_REMOVE,
		Body:       body,
		CreateTime: article.CreateTime,
	}
	Message.Save(message)
}
开发者ID:hxdyxd,项目名称:pugo,代码行数:25,代码来源:article.go


示例6: getDynamic

func getDynamic(client *http.Client, importPath, tag, etag string) (pdoc *hv.Package, err error) {
	match, err := fetchMeta(client, importPath)
	if err != nil {
		return nil, err
	}

	if match["projectRoot"] != importPath {
		rootMatch, err := fetchMeta(client, match["projectRoot"])
		if err != nil {
			return nil, err
		}
		if rootMatch["projectRoot"] != match["projectRoot"] {
			return nil, com.NotFoundError{"Project root mismatch."}
		}
	}

	pdoc, err = getStatic(client, com.Expand("{repo}{dir}", match), tag, etag)
	if err == errNoMatch {
		//pdoc, err = getVCSDoc(client, match, etag)
	}
	if err != nil {
		return nil, err
	}

	if pdoc != nil {
		pdoc.ImportPath = importPath
		pdoc.ProjectName = match["projectName"]
	}

	return pdoc, err
}
开发者ID:juju2013,项目名称:gowalker,代码行数:31,代码来源:crawl.go


示例7: RenderIssueIndexPattern

// RenderIssueIndexPattern renders issue indexes to corresponding links.
func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string, metas map[string]string) []byte {
	urlPrefix = cutoutVerbosePrefix(urlPrefix)

	pattern := IssueNumericPattern
	if metas["style"] == ISSUE_NAME_STYLE_ALPHANUMERIC {
		pattern = IssueAlphanumericPattern
	}

	ms := pattern.FindAll(rawBytes, -1)
	for _, m := range ms {
		if m[0] == ' ' || m[0] == '(' {
			m = m[1:] // ignore leading space or opening parentheses
		}
		var link string
		if metas == nil {
			link = fmt.Sprintf(`<a href="%s/issues/%s">%s</a>`, urlPrefix, m[1:], m)
		} else {
			// Support for external issue tracker
			if metas["style"] == ISSUE_NAME_STYLE_ALPHANUMERIC {
				metas["index"] = string(m)
			} else {
				metas["index"] = string(m[1:])
			}
			link = fmt.Sprintf(`<a href="%s">%s</a>`, com.Expand(metas["format"], metas), m)
		}
		rawBytes = bytes.Replace(rawBytes, m, []byte(link), 1)
	}
	return rawBytes
}
开发者ID:ChamberJin,项目名称:gogs,代码行数:30,代码来源:markdown.go


示例8: getDynamic

func getDynamic(importPath, etag string) (pdoc *Package, err error) {
	match, err := fetchMeta(importPath)
	if err != nil {
		return nil, err
	}

	if match["projectRoot"] != importPath {
		rootMatch, err := fetchMeta(match["projectRoot"])
		if err != nil {
			return nil, err
		}
		if rootMatch["projectRoot"] != match["projectRoot"] {
			return nil, errors.New("Project root mismatch")
		}
	}

	if strings.HasPrefix(match["repo"], "go.googlesource.com") {
		match["dir"] = "/" + path.Base(match["repo"])
		match["repo"] = "github.com/golang"
	}

	pdoc, err = getStatic(com.Expand("{repo}{dir}", match), etag)
	if err == ErrNoServiceMatch {
		pdoc, err = getVCSDoc(match, etag)
	} else if pdoc != nil {
		pdoc.ImportPath = importPath
	}
	if err != nil {
		return nil, err
	}

	return pdoc, err
}
开发者ID:ewindfall,项目名称:gowalker,代码行数:33,代码来源:crawl.go


示例9: renderEditPage

func renderEditPage(ctx *middleware.Context, documentPath string) {
	if setting.Extension.EnableEditPage {
		ctx.Data["EditPageLink"] = com.Expand(setting.Extension.EditPageLinkFormat, map[string]string{
			"lang": ctx.Locale.Language(),
			"blob": documentPath + ".md",
		})
	}
}
开发者ID:TDose,项目名称:peach,代码行数:8,代码来源:docs.go


示例10: NewSearch

func NewSearch(key string) (*SearchPackages, error) {
	url := com.Expand(searchApi, map[string]string{
		"keyword": key,
	})
	packages := new(SearchPackages)
	err := com.HttpGetJSON(httpClient, url, packages)
	return packages, err
}
开发者ID:kissthink,项目名称:gobuild2,代码行数:8,代码来源:gowalker.go


示例11: ExampleExpand

func ExampleExpand() {
	match := map[string]string{
		"domain":    "gowalker.org",
		"subdomain": "github.com",
	}
	s := "http://{domain}/{subdomain}/{0}/{1}"
	fmt.Println(com.Expand(s, match, "Unknwon", "gowalker"))
	// Output: http://gowalker.org/github.com/Unknwon/gowalker
}
开发者ID:matm,项目名称:gobuild,代码行数:9,代码来源:example_test.go


示例12: getBitbucketArchive

func getBitbucketArchive(client *http.Client, match map[string]string, n *Node) error {
	match["sha"] = n.Revision

	// Downlaod archive.
	if err := com.HttpGetToFile(client,
		com.Expand("https://bitbucket.org/{owner}/{repo}/get/{sha}.zip", match), nil, n.ArchivePath); err != nil {
		return fmt.Errorf("fail to download archive(%s): %v", n.ImportPath, err)
	}
	return nil
}
开发者ID:harryyeh,项目名称:switch,代码行数:10,代码来源:bitbucket.go


示例13: GetMission

func (r *Rpc) GetMission(args *HostInfo, rep *Mission) error {
	log.Debugf("arch: %v, host: %v", args.Arch, args.Host)
	tasks, err := models.GetAvaliableTasks(args.Os, args.Arch)
	if err == models.ErrTaskNotAvaliable {
		rep.Idle = time.Second * 3
		return nil
	}
	if err != nil {
		log.Errorf("rpc: get mission error: %v", err)
		return err
	}

	task := tasks[0] // use first task
	rep.Mid = task.Id
	rep.Repo = task.Repo
	rep.PushURI = task.PushType + ":" + task.PushValue
	rep.CgoEnable = task.CgoEnable
	rep.PkgInfo, _ = json.MarshalIndent(PkgInfo{
		PushURI:     task.PushType + ":" + task.PushValue,
		Author:      []string{"unknown"},
		Description: "unknown",
	}, "", "    ")

	for _, tk := range tasks {
		if tk.TagBranch == "" {
			tk.TagBranch = "temp-" + tk.PushType + ":" + tk.PushValue
		}
		filename := fmt.Sprintf("%s-%s-%s.%s", filepath.Base(rep.Repo.Uri), tk.Os, tk.Arch, "zip")
		if tk.Action == models.AC_SRCPKG {
			filename = fmt.Sprintf("%s-all-source.%s", filepath.Base(rep.Repo.Uri), "zip")
		}
		key := com.Expand("m{tid}/{reponame}/br-{branch}/{filename}", map[string]string{
			"tid":      strconv.Itoa(int(rep.Mid)),
			"reponame": rep.Repo.Uri,
			"branch":   tk.TagBranch,
			"filename": filename,
		})
		bi := BuildInfo{
			Action:     tk.Action,
			Os:         tk.Os,
			Arch:       tk.Arch,
			UploadType: UT_QINIU,
			UploadData: base.Objc2Str(QiniuInfo{
				Bulket: defaultBulket,
				Key:    key,
				Token:  qntoken(key),
			}),
		}
		rep.Builds = append(rep.Builds, bi)
	}
	return nil
}
开发者ID:kissthink,项目名称:gobuild2,代码行数:52,代码来源:xrpc.go


示例14: getGoogleVCS

func getGoogleVCS(client *http.Client, match map[string]string) error {
	// Scrape the HTML project page to find the VCS.
	p, err := com.HttpGetBytes(client, com.Expand("http://code.google.com/p/{repo}/source/checkout", match), nil)
	if err != nil {
		return errors.New("doc.getGoogleVCS(" + match["importPath"] + ") -> " + err.Error())
	}
	m := googleRepoRe.FindSubmatch(p)
	if m == nil {
		return com.NotFoundError{"Could not VCS on Google Code project page."}
	}
	match["vcs"] = string(m[1])
	return nil
}
开发者ID:nashtsai,项目名称:gopm,代码行数:13,代码来源:google.go


示例15: getGoogleVCS

func getGoogleVCS(client *http.Client, match map[string]string) error {
	// Scrape the HTML project page to find the VCS.
	p, err := com.HttpGetBytes(client, com.Expand("http://code.google.com/p/{repo}/source/checkout", match), nil)
	if err != nil {
		return fmt.Errorf("fail to fetch page: %v", err)
	}
	m := googleRepoRe.FindSubmatch(p)
	if m == nil {
		return com.NotFoundError{"Could not VCS on Google Code project page."}
	}
	match["vcs"] = string(m[1])
	return nil
}
开发者ID:harryyeh,项目名称:switch,代码行数:13,代码来源:google.go


示例16: getGoogleVCS

func getGoogleVCS(match map[string]string) error {
	// Scrape the HTML project page to find the VCS.
	stdout, _, err := com.ExecCmd("curl", com.Expand("http://code.google.com/p/{repo}/source/checkout", match))
	if err != nil {
		return errors.New("doc.getGoogleVCS(" + match["importPath"] + ") -> " + err.Error())
	}
	m := googleRepoRe.FindSubmatch([]byte(stdout))
	if m == nil {
		return com.NotFoundError{"Could not VCS on Google Code project page."}
	}
	match["vcs"] = string(m[1])
	return nil
}
开发者ID:NicholeGit,项目名称:gowalker,代码行数:13,代码来源:google.go


示例17: getGolangRevision

func getGolangRevision(client *http.Client, n *Node) error {
	match := map[string]string{}
	{
		m := golangPattern.FindStringSubmatch(n.ImportPath)
		for i, n := range golangPattern.SubexpNames() {
			if n != "" {
				match[n] = m[i]
			}
		}
		setupGoogleMatch(match)
	}
	match["repo"] = "go"

	if len(n.Value) == 0 {
		// Scrape the HTML project page to find the VCS.
		p, err := com.HttpGetBytes(client, com.Expand("http://code.google.com/p/{repo}/source/checkout", match), nil)
		if err != nil {
			return fmt.Errorf("fail to fetch page: %v", err)
		}
		m := googleRepoRe.FindSubmatch(p)
		if m == nil {
			return fmt.Errorf("cannot find VCS on Google Code project page")
		}
		match["vcs"] = string(m[1])
		n.Value = defaultTags[match["vcs"]]
	}
	match["tag"] = n.Value
	data, err := com.HttpGetBytes(client, com.Expand("http://code.google.com/p/{repo}/source/browse/?repo={subrepo}&r={tag}", match), nil)
	if err != nil {
		return fmt.Errorf("fail to get revision(%s): %v", n.ImportPath, err)
	}
	m := googleRevisionPattern.FindSubmatch(data)
	if m == nil {
		return fmt.Errorf("cannot find revision in page: %s", n.ImportPath)
	}
	n.Revision = strings.TrimPrefix(string(m[0]), `_setViewedRevision('`)
	n.ArchivePath = path.Join(setting.ArchivePath, n.ImportPath, n.Revision+".zip")
	return nil
}
开发者ID:harryyeh,项目名称:switch,代码行数:39,代码来源:google.go


示例18: getGithubArchive

func getGithubArchive(client *http.Client, match map[string]string, n *Node) error {
	match["sha"] = n.Revision
	// match["cred"] = setting.GithubCredentials

	// We use .zip here.
	// zip: https://github.com/{owner}/{repo}/archive/{sha}.zip
	// tarball: https://github.com/{owner}/{repo}/tarball/{sha}

	// Downlaod archive.
	if err := com.HttpGetToFile(client,
		com.Expand("https://github.com/{owner}/{repo}/archive/{sha}.zip", match), nil, n.ArchivePath); err != nil {
		return fmt.Errorf("fail to download archive(%s): %v", n.ImportPath, err)
	}
	return nil
}
开发者ID:harryyeh,项目名称:switch,代码行数:15,代码来源:github.go


示例19: getGoogleArchive

func getGoogleArchive(client *http.Client, match map[string]string, n *Node) error {
	setupGoogleMatch(match)
	match["tag"] = n.Revision

	if match["vcs"] == "svn" {
		return fmt.Errorf("SVN not support yet")
	} else {
		// Downlaod archive.
		if err := com.HttpGetToFile(client,
			com.Expand("http://{subrepo}{dot}{repo}.googlecode.com/archive/{tag}.zip", match), nil, n.ArchivePath); err != nil {
			return fmt.Errorf("fail to download archive(%s): %v", n.ImportPath, err)
		}
	}
	return nil
}
开发者ID:harryyeh,项目名称:switch,代码行数:15,代码来源:google.go


示例20: GetPkgInfo

// https://gowalker.org/api/v1/pkginfo?pkgname=github.com/astaxie/beego
func GetPkgInfo(pkgname string) (*PackageItem, error) {
	err := RefreshPkg(pkgname)
	if err != nil {
		return nil, err
	}
	url := com.Expand(pkginfoApi, map[string]string{
		"pkgname": pkgname,
	})
	pkginfo := new(PackageItem)
	if err = com.HttpGetJSON(httpClient, url, pkginfo); err != nil {
		return nil, err
	}
	if pkginfo.Id == 0 {
		return nil, ErrPkgNotExists
	}
	return pkginfo, err
}
开发者ID:kissthink,项目名称:gobuild2,代码行数:18,代码来源:gowalker.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang com.HomeDir函数代码示例发布时间:2022-05-28
下一篇:
Golang com.ExecCmdDirBytes函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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