What are some common beginner mistakes in Go programming?

By: | Post date: March 15, 2017 | Comments: No Comments
Posted in categories: Information Technology

They’re minor things, but they’re things I keep slipping up on:

  • Sometimes Golang hides the difference between a type and the pointer to the type. That doesn’t mean the asterisk is decorative. Most of the time, Golang doesn’t hide the difference, and you do need to put that asterisk in.
  • It is idiomatic to assign foo, err := x multiple times in a row. Golang will let you repeat err as the second assigned variable. But it won’t let you repeat it as the first element: that’s always meant to be a new variable.
  • If there’s any fluidity in your programming at all, the libraries you import will always lag behind the libraries you use.
  • Strings are not byte arrays.

Compared to the smoking ruination that accompanies beginner’s errors in C, these are on the benign side, especially as they are often caught by the editor.

Leave a Reply

%d bloggers like this: