sitemap

package module
v0.0.0-...-2bca3a7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2020 License: MIT Imports: 2 Imported by: 0

README

sitemap

Build Status GoDoc Go Report Card

Sitemap protocol library in Go.

Install

Go version 1.13

go get github.com/FoodyTech/sitemap

Example

mysite := `<some sitemap in XML>`

smap, err := sitemap.ParseString(mysite)
if err != nil {
    // process on error
}

for _, url := smap.URL {
    println(url.Location)
    println(url.LastModification)
    println()
}

Documentation

See these docs.

License

MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder helps to build own site map.

func (*Builder) Add

func (b *Builder) Add(loc string)

Add a given loc to the site map.

func (*Builder) AddURL

func (b *Builder) AddURL(url URL)

Add a given URL to the site map.

func (*Builder) Build

func (b *Builder) Build() Sitemap

Build the site map.

type Sitemap

type Sitemap struct {
	XMLName xml.Name `xml:"urlset"     json:"-"`
	Text    string   `xml:",chardata"  json:"text"`
	Xmlns   string   `xml:"xmlns,attr" json:"-"`
	URL     []URL    `xml:"url"        json:"url"`
}

Sitemap represents a sitemap protocol. See: https://www.sitemaps.org/protocol.html

func Parse

func Parse(r io.Reader) (*Sitemap, error)

Parse sitemap from a given io.Reader.

func ParseBytes

func ParseBytes(buf []byte) (*Sitemap, error)

Parse sitemap from the given bytes.

func ParseString

func ParseString(s string) (*Sitemap, error)

Parse sitemap from a given string.

type URL

type URL struct {
	Text             string `xml:",chardata"  json:"chardata"`
	Location         string `xml:"loc"        json:"loc"`
	LastModification string `xml:"lastmod"    json:"lastmod"`
	ChangeFrequency  string `xml:"changefreq" json:"changefreq"`
	Priority         string `xml:"priority"   json:"priority"`
}

URL represents Sitemap URL entry.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL