2. A Go Primer

One of the goals of Go was a consistent and unambiguous syntax. This makes it easy for tools to examine Go programs, and also makes it easy to learn. Unhelpful compiler errors make it difficult to learn a language, as anyone who has made a typo in C++ code using templates will know.

In C, for example, function and global variable declarations have almost the same syntax. This means that the compiler can’t easily tell which one you meant if you make an error. It gives you helpful error messages like “expected ;” on a line where you don’t think a semicolon is expected at all.

The Go grammar was designed to make it possible for the compiler to tell you more accurately what you did wrong. It was also designed to avoid the need to state ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.