Explorar el Código

more than 8 articles will be dropped

master
Patrick Peng Sun hace 8 años
padre
commit
3962f8adc6
Se han modificado 1 ficheros con 7 adiciones y 7 borrados
  1. +7
    -7
      outMsg.go

+ 7
- 7
outMsg.go Ver fichero

} }


func buildNewsMsg(ToUserName, title, description string, articles []Article) (msg string) { func buildNewsMsg(ToUserName, title, description string, articles []Article) (msg string) {
count := len(articles)
if count <= 0 {
log.Fatal("using empty article to build NewsMsg")
msg = ""
return
}

count := 0
items := []string{} items := []string{}
for _, a := range articles { for _, a := range articles {
if count >= 8 {
err := errors.New("too many articles, only take first 8")
log.Fatal(err)
break
}
s := buildArticleItem(a) s := buildArticleItem(a)
items = append(items, s) items = append(items, s)
count++
} }
strItems := strings.Join(items, "") strItems := strings.Join(items, "")



Cargando…
Cancelar
Guardar