gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

README.md (6260B)


      1 ## gorilla/feeds
      2 [![GoDoc](https://godoc.org/github.com/gorilla/feeds?status.svg)](https://godoc.org/github.com/gorilla/feeds)
      3 [![Build Status](https://travis-ci.org/gorilla/feeds.svg?branch=master)](https://travis-ci.org/gorilla/feeds)
      4 
      5 feeds is a web feed generator library for generating RSS, Atom and JSON feeds from Go
      6 applications.
      7 
      8 ### Goals
      9 
     10  * Provide a simple interface to create both Atom & RSS 2.0 feeds
     11  * Full support for [Atom][atom], [RSS 2.0][rss], and [JSON Feed Version 1][jsonfeed] spec elements
     12  * Ability to modify particulars for each spec
     13 
     14 [atom]: https://tools.ietf.org/html/rfc4287
     15 [rss]: http://www.rssboard.org/rss-specification
     16 [jsonfeed]: https://jsonfeed.org/version/1
     17 
     18 ### Usage
     19 
     20 ```go
     21 package main
     22 
     23 import (
     24     "fmt"
     25     "log"
     26     "time"
     27     "github.com/gorilla/feeds"
     28 )
     29 
     30 func main() {
     31     now := time.Now()
     32     feed := &feeds.Feed{
     33         Title:       "jmoiron.net blog",
     34         Link:        &feeds.Link{Href: "http://jmoiron.net/blog"},
     35         Description: "discussion about tech, footie, photos",
     36         Author:      &feeds.Author{Name: "Jason Moiron", Email: "jmoiron@jmoiron.net"},
     37         Created:     now,
     38     }
     39 
     40     feed.Items = []*feeds.Item{
     41         &feeds.Item{
     42             Title:       "Limiting Concurrency in Go",
     43             Link:        &feeds.Link{Href: "http://jmoiron.net/blog/limiting-concurrency-in-go/"},
     44             Description: "A discussion on controlled parallelism in golang",
     45             Author:      &feeds.Author{Name: "Jason Moiron", Email: "jmoiron@jmoiron.net"},
     46             Created:     now,
     47         },
     48         &feeds.Item{
     49             Title:       "Logic-less Template Redux",
     50             Link:        &feeds.Link{Href: "http://jmoiron.net/blog/logicless-template-redux/"},
     51             Description: "More thoughts on logicless templates",
     52             Created:     now,
     53         },
     54         &feeds.Item{
     55             Title:       "Idiomatic Code Reuse in Go",
     56             Link:        &feeds.Link{Href: "http://jmoiron.net/blog/idiomatic-code-reuse-in-go/"},
     57             Description: "How to use interfaces <em>effectively</em>",
     58             Created:     now,
     59         },
     60     }
     61 
     62     atom, err := feed.ToAtom()
     63     if err != nil {
     64         log.Fatal(err)
     65     }
     66 
     67     rss, err := feed.ToRss()
     68     if err != nil {
     69         log.Fatal(err)
     70     }
     71 
     72     json, err := feed.ToJSON()
     73     if err != nil {
     74         log.Fatal(err)
     75     }
     76 
     77     fmt.Println(atom, "\n", rss, "\n", json)
     78 }
     79 ```
     80 
     81 Outputs:
     82 
     83 ```xml
     84 <?xml version="1.0" encoding="UTF-8"?>
     85 <feed xmlns="http://www.w3.org/2005/Atom">
     86   <title>jmoiron.net blog</title>
     87   <link href="http://jmoiron.net/blog"></link>
     88   <id>http://jmoiron.net/blog</id>
     89   <updated>2013-01-16T03:26:01-05:00</updated>
     90   <summary>discussion about tech, footie, photos</summary>
     91   <entry>
     92     <title>Limiting Concurrency in Go</title>
     93     <link href="http://jmoiron.net/blog/limiting-concurrency-in-go/"></link>
     94     <updated>2013-01-16T03:26:01-05:00</updated>
     95     <id>tag:jmoiron.net,2013-01-16:/blog/limiting-concurrency-in-go/</id>
     96     <summary type="html">A discussion on controlled parallelism in golang</summary>
     97     <author>
     98       <name>Jason Moiron</name>
     99       <email>jmoiron@jmoiron.net</email>
    100     </author>
    101   </entry>
    102   <entry>
    103     <title>Logic-less Template Redux</title>
    104     <link href="http://jmoiron.net/blog/logicless-template-redux/"></link>
    105     <updated>2013-01-16T03:26:01-05:00</updated>
    106     <id>tag:jmoiron.net,2013-01-16:/blog/logicless-template-redux/</id>
    107     <summary type="html">More thoughts on logicless templates</summary>
    108     <author></author>
    109   </entry>
    110   <entry>
    111     <title>Idiomatic Code Reuse in Go</title>
    112     <link href="http://jmoiron.net/blog/idiomatic-code-reuse-in-go/"></link>
    113     <updated>2013-01-16T03:26:01-05:00</updated>
    114     <id>tag:jmoiron.net,2013-01-16:/blog/idiomatic-code-reuse-in-go/</id>
    115     <summary type="html">How to use interfaces &lt;em&gt;effectively&lt;/em&gt;</summary>
    116     <author></author>
    117   </entry>
    118 </feed>
    119 
    120 <?xml version="1.0" encoding="UTF-8"?>
    121 <rss version="2.0">
    122   <channel>
    123     <title>jmoiron.net blog</title>
    124     <link>http://jmoiron.net/blog</link>
    125     <description>discussion about tech, footie, photos</description>
    126     <managingEditor>jmoiron@jmoiron.net (Jason Moiron)</managingEditor>
    127     <pubDate>2013-01-16T03:22:24-05:00</pubDate>
    128     <item>
    129       <title>Limiting Concurrency in Go</title>
    130       <link>http://jmoiron.net/blog/limiting-concurrency-in-go/</link>
    131       <description>A discussion on controlled parallelism in golang</description>
    132       <pubDate>2013-01-16T03:22:24-05:00</pubDate>
    133     </item>
    134     <item>
    135       <title>Logic-less Template Redux</title>
    136       <link>http://jmoiron.net/blog/logicless-template-redux/</link>
    137       <description>More thoughts on logicless templates</description>
    138       <pubDate>2013-01-16T03:22:24-05:00</pubDate>
    139     </item>
    140     <item>
    141       <title>Idiomatic Code Reuse in Go</title>
    142       <link>http://jmoiron.net/blog/idiomatic-code-reuse-in-go/</link>
    143       <description>How to use interfaces &lt;em&gt;effectively&lt;/em&gt;</description>
    144       <pubDate>2013-01-16T03:22:24-05:00</pubDate>
    145     </item>
    146   </channel>
    147 </rss>
    148 
    149 {
    150   "version": "https://jsonfeed.org/version/1",
    151   "title": "jmoiron.net blog",
    152   "home_page_url": "http://jmoiron.net/blog",
    153   "description": "discussion about tech, footie, photos",
    154   "author": {
    155     "name": "Jason Moiron"
    156   },
    157   "items": [
    158     {
    159       "id": "",
    160       "url": "http://jmoiron.net/blog/limiting-concurrency-in-go/",
    161       "title": "Limiting Concurrency in Go",
    162       "summary": "A discussion on controlled parallelism in golang",
    163       "date_published": "2013-01-16T03:22:24.530817846-05:00",
    164       "author": {
    165         "name": "Jason Moiron"
    166       }
    167     },
    168     {
    169       "id": "",
    170       "url": "http://jmoiron.net/blog/logicless-template-redux/",
    171       "title": "Logic-less Template Redux",
    172       "summary": "More thoughts on logicless templates",
    173       "date_published": "2013-01-16T03:22:24.530817846-05:00"
    174     },
    175     {
    176       "id": "",
    177       "url": "http://jmoiron.net/blog/idiomatic-code-reuse-in-go/",
    178       "title": "Idiomatic Code Reuse in Go",
    179       "summary": "How to use interfaces \u003cem\u003eeffectively\u003c/em\u003e",
    180       "date_published": "2013-01-16T03:22:24.530817846-05:00"
    181     }
    182   ]
    183 }
    184 ```
    185