mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Properly scope Config to the wtf package and remove it as a dependency from everywhere else
This commit is contained in:
@@ -6,13 +6,9 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/olebedev/config"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
// Config is a pointer to the global config object
|
||||
var Config *config.Config
|
||||
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
result string
|
||||
@@ -39,9 +35,9 @@ func (widget *Widget) Refresh() {
|
||||
//this method reads the config and calls wttr.in for pretty weather
|
||||
func (widget *Widget) prettyWeather() {
|
||||
client := &http.Client{}
|
||||
widget.unit = Config.UString("wtf.mods.prettyweather.unit", "m")
|
||||
widget.city = Config.UString("wtf.mods.prettyweather.city", "")
|
||||
widget.view = Config.UString("wtf.mods.prettyweather.view", "0")
|
||||
widget.unit = wtf.Config.UString("wtf.mods.prettyweather.unit", "m")
|
||||
widget.city = wtf.Config.UString("wtf.mods.prettyweather.city", "")
|
||||
widget.view = wtf.Config.UString("wtf.mods.prettyweather.view", "0")
|
||||
req, err := http.NewRequest("GET", "https://wttr.in/"+widget.city+"?"+widget.view+"?"+widget.unit, nil)
|
||||
if err != nil {
|
||||
widget.result = fmt.Sprintf("%s", err.Error())
|
||||
|
||||
Reference in New Issue
Block a user