better emoji support
This commit is contained in:
		
							parent
							
								
									2e265618d3
								
							
						
					
					
						commit
						8ff19a6e56
					
				
							
								
								
									
										
											BIN
										
									
								
								go-weather
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								go-weather
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										5
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								go.mod
									
									
									
									
									
								
							| @ -2,10 +2,7 @@ module go-weather | |||||||
| 
 | 
 | ||||||
| go 1.17 | go 1.17 | ||||||
| 
 | 
 | ||||||
| require ( | require github.com/fatih/color v1.13.0 | ||||||
| 	github.com/fatih/color v1.13.0 |  | ||||||
| 	github.com/kyokomi/emoji v2.2.4+incompatible |  | ||||||
| ) |  | ||||||
| 
 | 
 | ||||||
| require ( | require ( | ||||||
| 	github.com/mattn/go-colorable v0.1.12 // indirect | 	github.com/mattn/go-colorable v0.1.12 // indirect | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.sum
									
									
									
									
									
								
							| @ -1,7 +1,5 @@ | |||||||
| github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= | github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= | ||||||
| github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= | 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.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 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= | ||||||
| github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= | github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= | ||||||
|  | |||||||
							
								
								
									
										17
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								main.go
									
									
									
									
									
								
							| @ -11,7 +11,6 @@ import ( | |||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"github.com/fatih/color" | 	"github.com/fatih/color" | ||||||
| 	"github.com/kyokomi/emoji" |  | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| type WeatherAPI struct { | type WeatherAPI struct { | ||||||
| @ -144,19 +143,19 @@ func iconToEmoji(icon string) { | |||||||
| 	var em string | 	var em string | ||||||
| 	switch icon { | 	switch icon { | ||||||
| 	case "Clouds": | 	case "Clouds": | ||||||
| 		em = ":cloud:" | 		em = "☁️" | ||||||
| 	case "Drizzle": | 	case "Drizzle": | ||||||
| 		em = ":rain:" | 		em = "🌧️" | ||||||
| 	case "Rain": | 	case "Rain": | ||||||
| 		em = ":rain:" | 		em = "🌧️" | ||||||
| 	case "Snow": | 	case "Snow": | ||||||
| 		em = ":snow:" | 		em = "❄️" | ||||||
| 	case "Clear": | 	case "Clear": | ||||||
| 		em = ":sun:" | 		em = "☀️" | ||||||
| 	default: | 	default: | ||||||
| 		em = ":sun" | 		em = "☀️" | ||||||
| 	} | 	} | ||||||
| 	emoji.Printf(em) | 	fmt.Printf(em) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func printWeather(data WeatherAPI) { | func printWeather(data WeatherAPI) { | ||||||
| @ -182,7 +181,7 @@ func printWeather(data WeatherAPI) { | |||||||
| 
 | 
 | ||||||
| 	boldWhite.Printf("Location: ") | 	boldWhite.Printf("Location: ") | ||||||
| 	fmt.Printf("%v, %v\n", str_loc, str_code) | 	fmt.Printf("%v, %v\n", str_loc, str_code) | ||||||
| 	boldWhite.Printf("Weather: ") | 	boldWhite.Printf("Weather:") | ||||||
| 	iconToEmoji(str_weather_icon) | 	iconToEmoji(str_weather_icon) | ||||||
| 	fmt.Printf(" %v (%v)\n", str_weather, str_weather_detail) | 	fmt.Printf(" %v (%v)\n", str_weather, str_weather_detail) | ||||||
| 	boldWhite.Printf("Temp: ") | 	boldWhite.Printf("Temp: ") | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user