Skip to content

Small design details I like in Go

Go101 edited this page Sep 23, 2020 · 8 revisions
  1. Go supports using aValue.Method as a function value without losing the aValue context. This is a so natural feature but I find that no other popular static languages support it and even some dynamic languages don't support it well.
  2. Go supports declaring methods for any kinds of types
  3. Go supports using different import names to distinguish same-name imported packages.
  4. Except rare dot import style uses, Go forces using pkg. prefix to reference resources from imported packages.
  5. Many operations on nil values don't cause panics.
  6. Many variations of for loops.
  7. The position of the default branch in a switch or select code block can be arbitrary.
  8. Go supports declaring types in function bodies.
  9. Go supports nesting function bodies in function bodies.
  10. The type deduction rule for the left untyped operand of a bit-shift operation depends on whether or not the right operand is a constant.
  11. In some scenarios, it is ok to use array pointers as arrays.
  12. Go disallows cyclic imports.
  13. v++ and v-- can only be used as statements.
  14. non-boolean values can't be used as booleans.
Clone this wiki locally