better emoji support

master
Simon Kellet 3 years ago
parent 2e265618d3
commit 8ff19a6e56
  1. BIN
      go-weather
  2. 5
      go.mod
  3. 2
      go.sum
  4. 17
      main.go

Binary file not shown.

@ -2,10 +2,7 @@ module go-weather
go 1.17
require (
github.com/fatih/color v1.13.0
github.com/kyokomi/emoji v2.2.4+incompatible
)
require github.com/fatih/color v1.13.0
require (
github.com/mattn/go-colorable v0.1.12 // indirect

@ -1,7 +1,5 @@
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/kyokomi/emoji v2.2.4+incompatible h1:np0woGKwx9LiHAQmwZx79Oc0rHpNw3o+3evou4BEPv4=
github.com/kyokomi/emoji v2.2.4+incompatible/go.mod h1:mZ6aGCD7yk8j6QY6KICwnZ2pxoszVseX1DNoGtU2tBA=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=

@ -11,7 +11,6 @@ import (
"time"
"github.com/fatih/color"
"github.com/kyokomi/emoji"
)
type WeatherAPI struct {
@ -144,19 +143,19 @@ func iconToEmoji(icon string) {
var em string
switch icon {
case "Clouds":
em = ":cloud:"
em = ""
case "Drizzle":
em = ":rain:"
em = "🌧"
case "Rain":
em = ":rain:"
em = "🌧"
case "Snow":
em = ":snow:"
em = ""
case "Clear":
em = ":sun:"
em = ""
default:
em = ":sun"
em = ""
}
emoji.Printf(em)
fmt.Printf(em)
}
func printWeather(data WeatherAPI) {
@ -182,7 +181,7 @@ func printWeather(data WeatherAPI) {
boldWhite.Printf("Location: ")
fmt.Printf("%v, %v\n", str_loc, str_code)
boldWhite.Printf("Weather: ")
boldWhite.Printf("Weather:")
iconToEmoji(str_weather_icon)
fmt.Printf(" %v (%v)\n", str_weather, str_weather_detail)
boldWhite.Printf("Temp: ")

Loading…
Cancel
Save