All series

Reading path

100 Mistakes in Golang

7 articles in this series

  1. 02

    Chapter 2

    2 Unnecessary nested code 能够提前返回的特殊判定就提前返回 if xxx { // .... return err }else{ // do X } 总是能够写为 if xxx{ return err } // do X Make expected execution …

    7 min
  2. 03

    Chapter 3

    17 Creating confusion with octal literals In Go, an integer literal starting with 0 is considered an octal integer (base 8). Note the integer literal …

    12 min
  3. 04

    Chapter 4

    30: Ignoring the fact that elements are copied in range loops type account struct { balance float32 } accounts := []account{ {balance: 100.}, …

    3 min
  4. 05

    Chapter 5

    36: Not understanding the concept of a rune The len built-in function applied on a string doesn’t return the number of characters; it returns the …

    3 min
  5. 06

    Chapter 6

    42: Not knowing which type of receiver to use In Go, we can attach either a value or a pointer receiver to a method. With a value receiver, Go makes a …

    5 min
  6. 07

    Chapter 7

    48: Panicking Panicking in Go should be used sparingly. We have seen two prominent cases, one to signal a programmer error and another where our …

    2 min
  7. 08-09

    Chapter 8 & 9

    55: Mixing up concurrency and parallelism Concurrency enables parallelism. Concurrency provides a structure to solve a problem with parts that may be …

    4 min