Przeglądaj źródła

fix most recent display

the slice syntax doesn't support "slice to x or len()", so we have to
use this idiom. i wonder what one does when wanting to do that and work
with a result, but the answer is either something obvious/idiomatic or
writing a function that does it.
Lucas Stadler 11 lat temu
rodzic
commit
5bfad71651
1 zmienionych plików z 5 dodań i 4 usunięć
  1. 5 4
      go/feeds.go

+ 5 - 4
go/feeds.go

@ -37,10 +37,11 @@ func main() {
37 37
			continue
38 38
		}
39 39
40
		fmt.Printf("%s: %s - %s\n", fn, f.Title, f.Description)
41
		fmt.Printf("%s: %d entries\n", fn, len(f.Items))
42
		for _, item := range f.Items[0:10] {
43
			fmt.Printf("%s: %s\n", fn, item.Title)
40
		fmt.Printf("%s: %s - %s (%d entries)\n", fn, f.Title, f.Description, len(f.Items))
41
		for i, item := range f.Items {
42
			if i < 10 {
43
				fmt.Printf("%s: %s\n", fn, item.Title)
44
			}
44 45
		}
45 46
	}
46 47
}