diff --git a/README.md b/README.md index b92a4e0..979b02b 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ go get git.streifling.com/jason/atom@latest ## Usage This library provides convenient functions to safely create and extend elements -and attributes of an Atom feed. This is because it can be hard to know all -pitfalls of RFC4287. The intended way of using atom is with these functions. +and attributes of Atom feeds. It also provides checks for all constructs' +adherence to RFC4287. ```go package main @@ -29,30 +29,28 @@ import ( ) func main() { - feed, err := atom.NewFeed("Example Feed") - if err != nil { + feed := atom.NewFeed("Example Feed") + feed.Title = atom.NewText("text", "Example Feed") + feed.ID = atom.NewID(atom.NewURN()) + if err := feed.Check(); err != nil { log.Fatalln(err) } author := atom.NewPerson("John Doe") author.Email = "john.doe@example.com" + if err := author.Check(); err != nil { + log.Fatalln(err) + } feed.AddAuthor(author) - entry, err := atom.NewEntry("First Entry") - if err != nil { + entry := atom.NewEntry("First Entry") + entry.ID = atom.NewID(atom.NewURN()) + entry.Content = atom.NewContent(atom.InlineText, "text", "This is the content of the first entry.") + if err := entry.Check(); err != nil { log.Fatalln(err) } - content, err := atom.NewContent(atom.InlineText, "text", "This is the content of the first entry.") - if err != nil { - log.Fatalln(err) - } - entry.Content = content feed.AddEntry(entry) - if err := feed.Check(); err != nil { - log.Fatalln(err) - } - feedString, err := feed.ToXML("utf-8") if err != nil { log.Fatalln(err) @@ -62,7 +60,7 @@ func main() { ``` It is also possible to use this library in a way similar to what other libraries -would provide. This is, of course, making it easier to make mistakes. +provide. ```go package main @@ -115,7 +113,7 @@ func main() { } ``` -The output of both ways of using it is an RFC4287 compliant Atom feed: +The output of both ways of using it is an RFC4287 compliant Atom feed. ```xml