-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[:GHPAGES:] Merge pull request #4 from navidys/doc_ghpage
[:GHPAGES:] - example update
- Loading branch information
Showing
6 changed files
with
225 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/navidys/gopensky" | ||
) | ||
|
||
func main() { | ||
conn, err := gopensky.NewConnection(context.Background(), "", "") | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
|
||
// retrieve all states information | ||
statesData, err := gopensky.GetStates(conn, 0, nil, nil, true) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(2) | ||
} | ||
|
||
for _, state := range statesData.States { | ||
longitude := "<nil>" | ||
latitude := "<nil>" | ||
|
||
if state.Longitude != nil { | ||
longitude = fmt.Sprintf("%f", *state.Longitude) | ||
} | ||
|
||
if state.Latitude != nil { | ||
latitude = fmt.Sprintf("%f", *state.Latitude) | ||
} | ||
|
||
fmt.Printf("ICAO24: %s, Longitude: %s, Latitude: %s, Origin Country: %s \n", | ||
state.Icao24, | ||
longitude, | ||
latitude, | ||
state.OriginCountry, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"time" | ||
|
||
"github.com/navidys/gopensky" | ||
) | ||
|
||
func main() { | ||
conn, err := gopensky.NewConnection(context.Background(), "", "") | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
|
||
// retrieve arrivals flights of: | ||
// airpor: LFPG (Charles de Gaulle) | ||
// being time: 1696755342 (Sunday October 08, 2023 08:55:42 UTC) | ||
// end time: 1696928142 (Tuesday October 10, 2023 08:55:42 UTC) | ||
|
||
flightsData, err := gopensky.GetArrivalsByAirport(conn, "LFPG", 1696755342, 1696928142) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(2) | ||
} | ||
|
||
for _, flightData := range flightsData { | ||
var depAirport string | ||
if flightData.EstDepartureAirport != nil { | ||
depAirport = *flightData.EstDepartureAirport | ||
} | ||
|
||
fmt.Printf("ICAO24: %s, Departure Airport: %4s, LastSeen: %s\n", | ||
flightData.Icao24, | ||
depAirport, | ||
time.Unix(flightData.LastSeen, 0), | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters