本文整理汇总了Golang中github.com/ChrisKaufmann/goutils.Tostr函数的典型用法代码示例。如果您正苦于以下问题:Golang Tostr函数的具体用法?Golang Tostr怎么用?Golang Tostr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Tostr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
}
示例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
}
示例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
}
示例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
}
示例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...)
}
示例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)
}
}
}
示例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
}
示例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)
}
}
}
示例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()
}
示例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")
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}