Skip to content

Instantly share code, notes, and snippets.

@annaleighsmith
Created April 23, 2022 00:53
Show Gist options
  • Save annaleighsmith/82b9ba27e77ae564b81e0e6cf7d0efc1 to your computer and use it in GitHub Desktop.
Save annaleighsmith/82b9ba27e77ae564b81e0e6cf7d0efc1 to your computer and use it in GitHub Desktop.
learning go, one of my first little bits of code
func main() {
now := time.Now()
m := make(map[int]string)
_ = now
_ = m
for i := 0; i < 13; i++ {
for i, month := range []string{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"} {
i += 1
m[i] = month
}
}
if v, found := m[int(now.Month())]; found {
day := strconv.FormatInt(int64(now.Day()), 10)
fmt.Printf("Today is %s %s, %d", v, day, now.Year())
} else {
fmt.Println("Error")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment