本文整理汇总了Golang中html.UnescapeString函数的典型用法代码示例。如果您正苦于以下问题:Golang UnescapeString函数的具体用法?Golang UnescapeString怎么用?Golang UnescapeString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UnescapeString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TrimString
// TrimString returns the specified number of characters from the
// specified string
func (viewHelper *ViewHelper) TrimString(s string, length int) string {
if len(s) <= length {
return html.UnescapeString(s)
}
return html.UnescapeString(s[0:length])
}
开发者ID:swizzley,项目名称:go-common,代码行数:9,代码来源:view_helper.go
示例2: fetch
func fetch(urls []string) Entries {
var result Entries
p := gofeed.NewParser()
for _, url := range urls {
resp, err := http.Get(url)
if err != nil {
log.Error("cannot fetch feed", "url", url, "error", err.Error())
continue
}
feed, err := p.Parse(resp.Body)
resp.Body.Close()
if err != nil {
log.Error("cannot parse feed", "url", url, "error", err.Error())
continue
}
for _, it := range feed.Items {
result = append(result, &Entry{
Feed: Feed{
Title: html.UnescapeString(feed.Title),
Link: feed.Link,
},
Title: html.UnescapeString(it.Title),
Link: it.Link,
Published: parseTime(it.Published),
})
}
}
return result
}
开发者ID:husio,项目名称:apps,代码行数:33,代码来源:feedreader.go
示例3: formatEvent
func (m *Module) formatEvent(event interface{}) string {
var msg string
switch t := event.(type) {
case anaconda.ApiError:
msg = fmt.Sprintf("Twitter API error %d: %s", t.StatusCode, t.Decoded.Error())
case anaconda.StatusDeletionNotice:
msg = fmt.Sprintf("Tweet %d has been deleted", t.Id)
case anaconda.DirectMessage:
msg = fmt.Sprintf("Direct message %d by %s sent to %s: %s", t.Id,
t.SenderScreenName, t.RecipientScreenName, html.UnescapeString(t.Text))
case anaconda.Tweet:
if t.RetweetedStatus != nil && t.User.Id != m.user.Id {
break
}
msg = fmt.Sprintf("Tweet %d by %s: %s", t.Id, t.User.ScreenName,
html.UnescapeString(t.Text))
case anaconda.EventTweet:
if t.Event.Event != "favorite" || t.Source.Id != m.user.Id {
break
}
text := html.UnescapeString(t.TargetObject.Text)
msg = fmt.Sprintf("%s favorited tweet %d by %s: %s",
t.Source.ScreenName, t.TargetObject.Id, t.Target.ScreenName, text)
}
return msg
}
开发者ID:feuerrot,项目名称:marvin,代码行数:29,代码来源:twitter.go
示例4: main
func main() {
raw := []string{
"hello",
"<i>Hello</i>",
"alert('hello');",
"foo & bar",
`"how are you?" He asked.`,
}
log.Println("html.EscapeString")
for _, s := range raw {
log.Printf("\t%s -> %s", s, html.EscapeString(s))
}
log.Println("html.UnescapeString(html.EscapeString)")
for _, s := range raw {
flipped := html.UnescapeString(html.EscapeString(s))
log.Printf("\t%s -> %s", s, flipped)
}
escaped := []string{
"á",
"»",
"·",
"<i>htllo</i>",
}
log.Println("html.UnescapeString")
for _, s := range escaped {
log.Printf("\t%s -> %s", s, html.UnescapeString(s))
}
}
开发者ID:agilecreativity,项目名称:go-playground,代码行数:32,代码来源:go-stdlib-html-escape.go
示例5: AddQuestions
func AddQuestions(db *sql.DB, newQns *stackongo.Questions) error {
defer UpdateTableTimes(db, "questions")
for _, item := range newQns.Items {
//INSERT IGNORE ensures that the same question won't be added again
stmt, err := db.Prepare("INSERT IGNORE INTO questions(question_id, question_title, question_URL, body, creation_date) VALUES (?, ?, ?, ?, ?)")
if err != nil {
return err
}
_, err = stmt.Exec(item.Question_id, html.UnescapeString(item.Title), item.Link, html.UnescapeString(StripTags(item.Body)), item.Creation_date)
if err != nil {
log.Println("Exec insertion for question failed!:\t", err)
continue
}
for _, tag := range item.Tags {
stmt, err = db.Prepare("INSERT IGNORE INTO question_tag(question_id, tag) VALUES(?, ?)")
if err != nil {
log.Println("question_tag insertion failed!:\t", err)
continue
}
_, err = stmt.Exec(item.Question_id, tag)
if err != nil {
log.Println("Exec insertion for question_tag failed!:\t", err)
continue
}
}
}
return nil
}
开发者ID:roboticdog,项目名称:mernessa_copy,代码行数:31,代码来源:databasing.go
最后编辑: kuteng 文档更新时间: 2021-08-23 19:14 作者:kuteng