qba73 / iss

International Space Station Go client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GoDoc Go Go Report Card GitHub GitHub go.mod Go version

ISS

ISS is a Go library for the the International Space Station API. It allows to get station's current lat and long coordinates.

Using the Go library

Import the library using

import github.com/qba73/iss

Creating a client

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
}

Retrieving ISS coordinates using client

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}

Retrieving ISS coordinates using functions

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

A complete example program

You can see an example program which retrieves the ISS coordinates in the examples/demo folder.

About

International Space Station Go client

License:Apache License 2.0


Languages

Language:Go 89.2%Language:Makefile 10.8%