Structs updated

This commit is contained in:
Andrew Scott 2022-08-02 23:26:28 -04:00
parent e74d4fe74f
commit 0e88ed0445
Signed by: a
GPG key ID: 3EB62D0BBB8DB381
5 changed files with 17 additions and 17 deletions

View file

@ -12,7 +12,7 @@ import (
)
// Use WAN address to obtain location data
func getLocation(app *application) {
func getLocation(app *Application) {
res, err := http.Get("https://ipinfo.io/json")
if err != nil {
@ -37,7 +37,7 @@ func getLocation(app *application) {
}
// Prompt user for location
func getPreciseLocation(app *application) {
func getPreciseLocation(app *Application) {
fmt.Print("\nEnter latitude: ")

View file

@ -12,7 +12,7 @@ import (
const version string = "0.2.0"
type weatherMain struct {
type Weather struct {
Temp float32 `json:"temp"`
FeelsLike float32 `json:"feels_like"`
HighTemp float32 `json:"temp_max"`
@ -21,18 +21,18 @@ type weatherMain struct {
Humidity uint `json:"humidity"`
}
type weatherWind struct {
type Wind struct {
Speed float32 `json:"speed"`
Gust float32 `json:"gust"`
}
type forecast struct {
type Forecast struct {
//Overview weatherOverview `json:"weather"`
Main weatherMain `json:"main"`
Wind weatherWind `json:"wind"`
Main Weather `json:"main"`
Wind Wind `json:"wind"`
}
type config struct {
type Config struct {
Units string `json:"units"`
Location string `json:"loc"`
Longitude string `json:"lat"`
@ -40,9 +40,9 @@ type config struct {
ApiKey string `json:"appid"`
}
type application struct {
Forecast forecast
Config config
type Application struct {
Forecast Forecast
Config Config
Version string
Client pb.RouteGuideClient
}
@ -62,14 +62,14 @@ func main() {
}
// Read API_KEY from .env and create app
cfg := config{
cfg := Config{
Units: "imperial",
ApiKey: os.Getenv("API_KEY"),
}
fcst := forecast{}
fcst := Forecast{}
app := application{
app := Application{
Config: cfg,
Forecast: fcst,
Version: version,

View file

@ -8,7 +8,7 @@ import (
"strings"
)
func mainMenu(app *application) {
func mainMenu(app *Application) {
// Display main menu
fmt.Println("\n=====================================================")

View file

@ -3,7 +3,7 @@ package main
import "fmt"
// Prints saved weather data to the terminal
func printWeather(app *application) {
func printWeather(app *Application) {
var unitStr string
if app.Config.Units == "imperial" {

View file

@ -8,7 +8,7 @@ import (
)
// Get and store the current forecast
func getCurrent(app *application) {
func getCurrent(app *Application) {
lat := "lat=" + app.Config.Latitude
lon := "&lon=" + app.Config.Longitude