当前位置:网站首页>Golang calculates constellations and signs based on birthdays

Golang calculates constellations and signs based on birthdays

2022-07-07 04:09:00 Golang Chinese community

## Calculate the constellation according to the birthday ```gofunc GetZodiac(month, day int) string { month = month - 1 var ( DAY_ARR = [12]int{20, 19, 21, 20, 21, 22, 23, 23, 23, 24, 23, 22} ZODIACS = [13]string{" Capricornus ", " Aquarius: ", " Pisces ", " Aries ", " Taurus ", " Gemini ", " Cancer ", " Leo ", " Virgo ", " libra ", " scorpio ", " Sagittarius ", " Capricornus "} ) if day < DAY_ARR[month] { return ZODIACS[month] } else { return ZODIACS[month+1] }}```## Calculate Zodiac according to birthday ```gofunc GetChineseZodiac(year int) string { var CHINESE_ZODIACS = [12]string{" rat ", " cattle ", " The tiger ", " rabbit ", " dragon ", " The snake ", " Horse ", " sheep ", " Monkey ", " chicken ", " Dog ", " The pig "} if year > 1900 { return CHINESE_ZODIACS[(year-1900)%len(CHINESE_ZODIACS)] } else { return "" }}```## Source code address golang Tool library https://github.com/xbmlz/gct
原网站

版权声明
本文为[Golang Chinese community]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207062123558492.html