Skip to content
/ awc.go Public

A Golang client for retrieving METAR and TAF data from the Aviation Weather Center

License

Notifications You must be signed in to change notification settings

lus/awc.go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

awc.go  

awc.go is a simple-to-use Go client for the Aviation Weather Center's Text Data Server which provides, among other things, METAR and TAF data directly from a government's source.

Usage

Adding the dependency

First of all you have to add the dependency to your project:

go get -u github.com/lus/awc.go/awc

Fetch METAR data

// We need to build a query to use to fetch our METAR data.
// Please refer to the documentation on pkg.go.dev for more information.
query := new(awc.METARQuery).
	Station("EDDF").
	HoursBeforeNow(1).
	MostRecent(true)

// Then we need to execute the just-built query.
response, err := awc.GetMETAR(query)
if err != nil {
	panic(err)
}

// Please keep in mind that, only because the GetMETAR function did not return any error, the request may still be flawed. 
if len(response.Warnings) > 0 {
	fmt.Printf("API warning(s): %s\n", strings.Join(response.Warnings)))
}
if len(response.Errors) > 0 {
	panic(fmt.Sprintf("API error(s): %s", strings.Join(response.Errors)))
}

fmt.Println(response.METARs[0].RawText)
// -> "EDDF 262150Z VRB02KT CAVOK 02/M01 Q1033 NOSIG"

Fetch TAF data

TAF data fetching is not yet implemented.

About

A Golang client for retrieving METAR and TAF data from the Aviation Weather Center

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages