Could you provide a link to where you found this code? I imagine it was done that way just for demonstrating some features of go, such as slicing and array lookups.
A simpler and faster way again would be to use a map. https://play.golang.org/p/ntjhesMsSA9 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8baa9dde-1c05-407b-a19b-382b5470b52a%40googlegroups.com.