4. Common Go Patterns

The first step to fluent use of any programming language is understanding the design patterns and idioms that are commonly used. Learning the syntax is only the first step to learning how to think in the language, akin to learning vocabulary and basic grammar in a natural language. People speaking a second language often make very amusing mistakes by literally translating idioms from their first language.

Programming languages are no different. If you’ve read C++ code written by Java programmers, or vice versa, then you’ve probably encountered this. Just translating an approach that you would use in one language into another will work (as long as both languages are equally expressive), but it will usually give horrible code. ...

Get The Go Programming Language Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.