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

Golang goutils.Tostr函数代码示例

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

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



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

示例1: DeleteExcludes

func (f Feed) DeleteExcludes() {
	el := f.Excludes()
	for _, e := range el {
		e = Escape_guid(e)
		if len(e) < 1 {
			continue
		}
		var query = "delete from ttrss_entries where feed_id=" + u.Tostr(f.ID) + " and title like '%" + e + "%'"
		var stmt, err = u.Sth(db, query)
		if err != nil {
			glog.Errorf("u.Sth(db,%s): %s", query, err)
			return
		}
		if _, err := stmt.Exec(); err != nil {
			glog.Errorf("DeleteExcludes.stmt.Exec: %s", err)
		}
	}
	ed := f.ExcludesData()
	for _, e := range ed {
		e = Escape_guid(e)
		if len(e) < 1 {
			continue
		}
		var query = "delete from ttrss_entries where feed_id=" + u.Tostr(f.ID) + " and content like '%" + e + "%'"
		var stmt, err = u.Sth(db, query)
		if err != nil {
			glog.Errorf("u.Sth(db,%s): %s", query, err)
			return
		}
		if _, err := stmt.Exec(); err != nil {
			glog.Errorf("stmt.Exec: %s", err)
		}
	}
	f.ClearCache()
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:35,代码来源:feed.go


示例2: GetAllCategories

func GetAllCategories() []Category {
	var allCats []Category
	var catids []int
	err := mc.Get("CategoryList", &catids)
	if err != nil {
		rows, err := stmtGetAllCats.Query()
		if err != nil {
			glog.Errorf("stmtGetAllCats: %s", err)
			return allCats
		}
		for rows.Next() {
			var cat Category
			rows.Scan(&cat.Name, &cat.UserName, &cat.Description, &cat.ID, &cat.Exclude)
			allCats = append(allCats, cat)
			catids = append(catids, cat.ID)
			go mc.Set("Category"+u.Tostr(cat.ID)+"_", cat)
		}
		go mc.Set("CategoryList", allCats)
	} else {
		for _, i := range catids {
			cat := GetCat(u.Tostr(i))
			allCats = append(allCats, cat)
		}
	}
	return allCats
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:26,代码来源:category.go


示例3: UnreadEntries

func (f Feed) UnreadEntries() (el []Entry) {
	mc.GetOr("Feed"+u.Tostr(f.ID)+"_unreadentries", &el, func() {
		el = f.GetEntriesByParam("unread = 1")
	})
	err := mc.Set("Feed"+u.Tostr(f.ID)+"_UnreadCount", len(el))
	if err != nil {
		glog.Errorf("mc.Set(Feed %v _UnreadCount, %v): %s", f.ID, len(el), err)
	}
	return el
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:10,代码来源:feed.go


示例4: UnreadEntries

func (c Category) UnreadEntries() (el []Entry) {
	mc.GetOr("Category"+u.Tostr(c.ID)+"_unreadentries", &el, func() {
		for _, f := range c.Feeds() {
			el = append(el, f.UnreadEntries()...)
		}
		sort.Sort(EntryList(el))
	})
	mc.SetTime("Category"+u.Tostr(c.ID)+"_UnreadCount", len(el), 60)
	return el
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:10,代码来源:category.go


示例5: ClearCache

func (c Category) ClearCache() {
	mc.DeleteLike("Category" + u.Tostr(c.ID) + "_")
	cl := mc.Find("Category" + u.Tostr(c.ID))
	mc.Delete(cl...)
	mcl := []string{"Category" + u.Tostr(c.ID) + "_", "Category" + u.Tostr(c.ID) + "_UnreadCount", "Category" + u.Tostr(c.ID) + "_Feeds"}
	for _, k := range mcl {
		mc.Delete(k)
	}
	mc.Delete(mcl...)
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:10,代码来源:category.go


示例6: CacheAllCats

func CacheAllCats() {
	for _, c := range GetAllCategories() {
		err := mc.Set("Category"+u.Tostr(c.ID)+"_", c)
		if err != nil {
			glog.Errorf("mc.Set(Category %v _: %s", c.ID, err)
		}
		err = mc.Set("Category"+u.Tostr(c.ID)+"_UnreadCount", c.Unread())
		if err != nil {
			glog.Errorf("mc.Set(Category %v _UnreadCount): %s", c.ID, err)
		}
	}
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:12,代码来源:category.go


示例7: CacheAllFeeds

func CacheAllFeeds() {
	for _, f := range GetAllFeeds() {
		err := mc.Set("Feed"+u.Tostr(f.ID)+"_", f)
		if err != nil {
			glog.Errorf("mc.Set(Feed%v): %s", f.ID, err)
		}
		err = mc.Set("Feed"+u.Tostr(f.ID)+"_UnreadCount", f.Unread())
		if err != nil {
			glog.Errorf("mc.Set(Feed %v _UnreadCount): %s", f.ID, err)
		}
	}
	return
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:13,代码来源:feed.go


示例8: ClearEntries

func (f Feed) ClearEntries() {
	var err error
	err = mc.Delete("Category" + u.Tostr(f.CategoryID) + "_unreadentries")
	if err != nil {
		if err.Error() != "memcache: cache miss" {
			glog.Errorf("mc.Delete(Category"+u.Tostr(f.CategoryID)+"_unreadentries: %s", err)
		}
	}
	err = mc.Delete("Feed" + u.Tostr(f.ID) + "_unreadentries")
	if err != nil {
		if err.Error() != "memcache: cache miss" {
			glog.Errorf("mc.Delete(Feed"+u.Tostr(f.CategoryID)+"_unreadentries: %s", err)
		}
	}
	err = mc.Delete("Category" + u.Tostr(f.CategoryID) + "_readentries")
	if err != nil {
		if err.Error() != "memcache: cache miss" {
			glog.Errorf("mc.Delete(Category"+u.Tostr(f.CategoryID)+"_readentries: %s", err)
		}
	}
	err = mc.Delete("Feed" + u.Tostr(f.ID) + "_readentries")
	if err != nil {
		if err.Error() != "memcache: cache miss" {
			glog.Errorf("mc.Delete(Feed"+u.Tostr(f.CategoryID)+"_readentries: %s", err)
		}
	}
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:27,代码来源:feed.go


示例9: ClearMarked

func (f Feed) ClearMarked() {
	err := mc.Delete("Feed" + u.Tostr(f.ID) + "_markedentries")
	if err != nil {
		if err.Error() != "memcache: cache miss" {
			glog.Errorf("mc.Delete(feed%v_markedentries): %s", f.ID, err)
		}
	}
	err = mc.Delete("Category" + u.Tostr(f.CategoryID) + "_markedentries")
	if err != nil {
		if err.Error() != "memcache: cache miss" {
			glog.Errorf("mc.Delete(Category%v_markedentries): %s", f.ID, err)
		}
	}
	f.ClearEntries()
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:15,代码来源:feed.go


示例10: Print

func (c Category) Print() {
	print("Category: " + u.Tostr(c.ID) + "\n" +
		"\tName:\t" + c.Name + "\n" +
		"\tDesc:\t" + c.Description + "\n" +
		"\tUser:\t" + c.UserName + "\n" +
		"\tExclude:\t" + c.Exclude + "\n")
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:7,代码来源:category.go


示例11: FeedsStr

func (c Category) FeedsStr() []string {
	f := c.Feeds()
	var feedstr []string
	for _, i := range f {
		feedstr = append(feedstr, u.Tostr(i.ID))
	}
	return feedstr
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:8,代码来源:category.go


示例12: MarkEntriesRead

func (f Feed) MarkEntriesRead(ids []string) (err error) {
	if len(ids) == 0 {
		err = fmt.Errorf("Ids is null")
		return err
	} else {
		// make sure they're all integers
		var id_list []string
		for _, i := range ids {
			if _, err := strconv.Atoi(i); err == nil {
				id_list = append(id_list, i)
			}
		}
		if len(id_list) < 1 {
			return fmt.Errorf("Not enough valid ids passed")
		}
		j := strings.Join(id_list, ",")
		sql := "update ttrss_entries set unread='0' where feed_id=" + u.Tostr(f.ID) + " and id in (" + j + ")"
		stmtUpdateMarkEntries, err := u.Sth(db, sql)
		if err != nil {
			glog.Errorf("u.Sth(db,%s): %s", sql, err)
			return err
		}
		if _, err = stmtUpdateMarkEntries.Exec(); err != nil {
			glog.Errorf("stmtUpdateMarkEntries.Exec(%s): %s", sql, err)
		}
		mc.Decrement("Category"+u.Tostr(f.CategoryID)+"_UnreadCount", uint64(len(ids)))
		mc.Decrement("Feed"+u.Tostr(f.ID)+"_UnreadCount", uint64(len(ids)))
		mc.Delete("Category" + u.Tostr(f.CategoryID) + "_unreadentries")
		mc.Delete("Feed" + u.Tostr(f.ID) + "_unreadentries")
		mc.Delete("Category" + u.Tostr(f.CategoryID) + "_readentries")
		mc.Delete("Feed" + u.Tostr(f.ID) + "_readentries")
	}
	return err
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:34,代码来源:feed.go


示例13: Unread

func (f Feed) Unread() (count int) {
	mc.GetOr("Feed"+u.Tostr(f.ID)+"_UnreadCount", &count, func() {
		err := stmtFeedUnread.QueryRow(f.ID).Scan(&count)
		if err != nil {
			glog.Errorf("stmtFeedUnread.QueryRow(%s): %s", f.ID, err)
		}
	})
	return count
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:9,代码来源:feed.go


示例14: ReadEntries

func (c Category) ReadEntries() (el []Entry) {
	mc.GetOr("Category"+u.Tostr(c.ID)+"_readentries", &el, func() {
		for _, f := range c.Feeds() {
			el = append(el, f.ReadEntries()...)
		}
		sort.Sort(EntryList(el))
	})
	return el
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:9,代码来源:category.go


示例15: MarkedEntries

func (c Category) MarkedEntries() (el []Entry) {
	mc.GetOr("Category"+u.Tostr(c.ID)+"_markedentries", &el, func() {
		for _, f := range c.Feeds() {
			el = append(el, f.MarkedEntries()...)
		}
		sort.Sort(EntryList(el))
		el = c.GetEntriesByParam("marked = 1")
	})
	return el
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:10,代码来源:category.go


示例16: Save

func (e Entry) Save(userName string) (err error) {
	if e.ID > 0 {
		if e.Title == "" {
			e.Title = "&nbsp"
		}
		if e.Link == "" {
			e.Link = ""
		}
		if e.Date == "" {
			e.Date = ""
		}
		if e.FeedID == 0 {
			e.FeedID = 0
		}
		if e.Marked == "" {
			e.Marked = "0"
		}
		if u.Tostr(e.Content) == "" {
			e.Content = template.HTML("")
		}
		var unread string = "1"
		if e.Unread == false {
			unread = "0"
		}
		_, err = stmtSaveEntry.Exec(e.Title, e.Link, e.Date, e.FeedID, e.Marked, unread, u.Tostr(e.Content), e.ID)
		if err != nil {
			glog.Errorf("stmtSaveEntry.Exec(%s,%s,%s,%s,%s,%s,%s,%s): %s", e.Title, e.Link, e.Date, e.FeedID, e.Marked, unread, u.Tostr(e.Content), e.ID, err)
			return err
		}
	} else {
		_, err := stmtAddEntry.Exec(e.Title, e.Link, e.FeedID, e.Marked, u.Tostr(e.Content), u.Tostr(e.ContentHash), e.GUID, userName)
		if err != nil {
			glog.Errorf("stmtAddEntry: %s", err)
			return err
		}
	}
	return err
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:38,代码来源:entry.go


示例17: Unread

func (c Category) Unread() (count int) {
	mcf := "Category" + u.Tostr(c.ID) + "_UnreadCount"
	err := mc.Get(mcf, &count)
	switch {
	case err != nil && err.Error() == "memcache: cache miss":
		for _, f := range c.Feeds() {
			count = count + f.Unread()
		}
		go mc.Set(mcf, count)
	case err != nil:
		glog.Errorf("mc.Get(%s): %s", mcf, err)
		return 0
	}
	return count
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:15,代码来源:category.go


示例18: GetFeedsWithoutCats

func GetFeedsWithoutCats(userName string) (allFeeds []Feed) {
	mc.GetOr("FeedsWithoutCats"+userName, &allFeeds, func() {
		print("-")
		rows, err := stmtGetFeedsWithoutCats.Query(userName)
		if err != nil {
			glog.Errorf("stmtGetFeedsWithoutCats.Query(%s): %s", userName, err)
		}
		for rows.Next() {
			var feed Feed
			rows.Scan(&feed.ID, &feed.Title, &feed.Url, &feed.LastUpdated, &feed.UserName, &feed.Public, &feed.CategoryID, &feed.ViewMode, &feed.AutoscrollPX, &feed.Exclude, &feed.ExcludeData, &feed.ErrorString, &feed.Expirey)
			if feed.Title == "" {
				feed.Title = "--untitled--"
			}
			feed.Title = html.UnescapeString(feed.Title)
			allFeeds = append(allFeeds, feed)
			mc.Set("Feed"+u.Tostr(feed.ID)+"_", feed) //cache the feed, because why not
		}
	})
	return allFeeds
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:20,代码来源:feed.go


示例19: GetCategories

func GetCategories(userName string) []Category {
	var allCats []Category
	var catids []int

	//Try getting a category list from cache
	rows, err := stmtGetCats.Query(userName)
	if err != nil {
		err.Error()
		return allCats
	}
	for rows.Next() {
		var cat Category
		rows.Scan(&cat.Name, &cat.UserName, &cat.Description, &cat.ID, &cat.Exclude)
		allCats = append(allCats, cat)
		catids = append(catids, cat.ID)
		go mc.Set("Category"+u.Tostr(cat.ID)+"_", cat)
	}
	go mc.Set("CategoryList_"+userName, catids)
	return allCats
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:20,代码来源:category.go


示例20: GetFeed

func GetFeed(id int) (feed Feed, err error) {
	if id < 1 {
		glog.Errorf("Non valid id passed to GetFeed %s", id)
		return feed, errors.New("feed Invalid ID")
	}
	var fcn = "Feed" + u.Tostr(id) + "_"

	mc.GetOr(fcn, &feed, func() {
		err = stmtGetFeed.QueryRow(id).Scan(&feed.ID, &feed.Title, &feed.Url, &feed.LastUpdated, &feed.UserName, &feed.Public, &feed.CategoryID, &feed.ViewMode, &feed.AutoscrollPX, &feed.Exclude, &feed.ExcludeData, &feed.ErrorString, &feed.Expirey)
		if err != nil {
			glog.Errorf("stmtGetFeed.QueryRow(%s).Scan(...): %s", id, err)
		}
		if feed.Title == "" {
			feed.Title = "--untitled--"
		}
		feed.Title = html.UnescapeString(feed.Title)
		err := mc.Set(fcn, feed)
		if err != nil {
			glog.Errorf("mc.Set(feed%v): %s", feed.ID, err)
		}
	})
	return feed, err
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:23,代码来源:feed.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang resource.DataCenter类代码示例发布时间:2022-05-23
下一篇:
Golang skills.Calc类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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