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

View file

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

View file

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

View file

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

View file

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