mirror of
https://github.com/golang/go
synced 2024-11-18 15:34:53 -07:00
24257c8cd2
Change-Id: Idda6e64580432cb9a731e4ebf4005ee4ceb4202d Reviewed-on: https://go-review.googlesource.com/1244 Reviewed-by: Andrew Gerrand <adg@golang.org>
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
// Copyright 2009 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Adapted from encoding/xml/read_test.go.
|
|
|
|
// Package atom defines XML data structures for an Atom feed.
|
|
package atom // import "golang.org/x/tools/blog/atom"
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"time"
|
|
)
|
|
|
|
type Feed struct {
|
|
XMLName xml.Name `xml:"http://www.w3.org/2005/Atom feed"`
|
|
Title string `xml:"title"`
|
|
ID string `xml:"id"`
|
|
Link []Link `xml:"link"`
|
|
Updated TimeStr `xml:"updated"`
|
|
Author *Person `xml:"author"`
|
|
Entry []*Entry `xml:"entry"`
|
|
}
|
|
|
|
type Entry struct {
|
|
Title string `xml:"title"`
|
|
ID string `xml:"id"`
|
|
Link []Link `xml:"link"`
|
|
Published TimeStr `xml:"published"`
|
|
Updated TimeStr `xml:"updated"`
|
|
Author *Person `xml:"author"`
|
|
Summary *Text `xml:"summary"`
|
|
Content *Text `xml:"content"`
|
|
}
|
|
|
|
type Link struct {
|
|
Rel string `xml:"rel,attr"`
|
|
Href string `xml:"href,attr"`
|
|
}
|
|
|
|
type Person struct {
|
|
Name string `xml:"name"`
|
|
URI string `xml:"uri,omitempty"`
|
|
Email string `xml:"email,omitempty"`
|
|
InnerXML string `xml:",innerxml"`
|
|
}
|
|
|
|
type Text struct {
|
|
Type string `xml:"type,attr"`
|
|
Body string `xml:",chardata"`
|
|
}
|
|
|
|
type TimeStr string
|
|
|
|
func Time(t time.Time) TimeStr {
|
|
return TimeStr(t.Format("2006-01-02T15:04:05-07:00"))
|
|
}
|