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

  • March 2017
    M T W T F S S
    « Feb   Apr »
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
  • Subscribe to Blog via Email

    Join 290 other subscribers

%d bloggers like this: