The mindset that you can master any programming language in a month is exactly what I meant in my previous post. There's a veritable cottage industry of "golang pitfalls" blog posts out there that show there are absolutely a lot of footguns in Go.
For example, what do you think the following should print?
values := []int{4, 8, 15, 16, 23, 42}
for value := range values {
fmt.Println(value)
}
I don't think there are very many people who would guess the integers 0 to 5.
I also like the following one:
ch := make(chan int)
ch <- 1
fmt.Println(<-ch)
What would this print? The only correct answer is sadly "fatal error: all goroutines are asleep - deadlock!".
Golang is a fine language and simpler than most, but sadly "simpler" is not the same as "simple".
For example, what do you think the following should print?
I don't think there are very many people who would guess the integers 0 to 5.I also like the following one:
What would this print? The only correct answer is sadly "fatal error: all goroutines are asleep - deadlock!".Golang is a fine language and simpler than most, but sadly "simpler" is not the same as "simple".