ISS is a Go library for the the International Space Station API. It allows to get station's current lat and long coordinates.
Import the library using
import github.com/qba73/iss
Create a new client object by calling iss.New()
client, err := iss.New()
if err != nil {
// handle error
}
If you want to use your http.Client
httpClient := http.Client{}
issClient, err := iss.New(iss.WithHTTPClient(&httpClient))
if err != nil {
// handle error
}
lat, long, err := issClient.GetPosition()
if err != nil {
// handle error
}
client, err := iss.New()
if err != nil {
// handle error
}
position, err := client.GetPosition()
if err != nil {
// handle error
}
fmt.Println(position)
// Output: {10.5489 1.3942}
The iss
package provides a high level functions for retrieving ISS coordinates.
lat, long, err := iss.GetPosition()
if err != nil {
// handle error
}
fmt.Println(lat, long)
// Output: -8.0037 14.7139
lat, long, err := iss.GetPositionAsStrings()
if err != nil {
// handle error
}
fmt.Println(lat, long)
// Output: -11.6732 17.4279
You can see an example program which retrieves the ISS coordinates in the examples/demo folder.