Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "launchpad.net/mgo"
- "os"
- "template"
- )
- type Comment struct {
- Author string
- Comment string
- }
- func main() {
- session, err := mgo.Mongo("localhost")
- if err != nil {
- panic(err)
- }
- defer session.Close()
- comments, _ := session.DB("test").C("comments").Find(nil).Iter()
- tpl := `{.repeated section @}
- {.section Author}{@}{.or}Anonymous{.end}: {Comment}
- {.end}
- `
- template := template.MustParse(tpl, nil)
- if err := template.Execute(os.Stdout, comments); err != nil {
- panic(err)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement