cap-go

module
v0.0.0-...-1257d68 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2015 License: MIT

README

cap-go

Build Status Coverage Status

A Go library for interacting with Common Alerting Protocol messages

The Common Alerting Protocol (CAP) is a simple but general format for exchanging all-hazard emergency alerts and public warnings over all kinds of networks.

The CAP specification can be found on the OASIS website.

Examples

Retrieving the CAP feed from NWS
package main

import (
    "fmt"
    "github.com/mark-adams/cap-go/cap"
)

func main(){
    feed, err := GetNWSAtomFeed()

    if err != nil {
        fmt.Errorf(err.Error())
        os.Exit(1)
    }

    fmt.Println(feed.ID)
}
Parsing a CAP alert
package main

import (
    "fmt"
    "github.com/mark-adams/cap-go/cap"
)

func main(){
    xmlData := []byte(`<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
        <alert xmlns='urn:oasis:names:tc:emergency:cap:1.2'>
            <identifier>NOAA-NWS-ALERTS-AR1253BA3B00A4.FloodWarning.1253BA3D4A94AR.LZKFLSLZK.342064b5a5aafb8265dfc3707d6a3b09</identifier>
            <sender>w-nws.webmaster@noaa.gov</sender>
            <sent>2015-08-15T20:45:00-05:00</sent>
            <status>Actual</status>
            <msgType>Alert</msgType>
            <scope>Public</scope>
            <info>
                <category>Met</category>
                <event>Flood Warning</event>
                <urgency>Expected</urgency>
                <severity>Moderate</severity>
                <certainty>Likely</certainty>
            </info>
        </alert>`)

    alert, err := ParseAlert(xmlData)

    if err != nil {
        fmt.Errorf(err.Error())
        os.Exit(1)
    }

    fmt.Println(alert.MessageID)
    fmt.Println(alert.Infos[0].EventType)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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