I'm Brett Slatkin and this is where I write about programming and related topics. You can contact me here or view my projects.

27 December 2012

How golang feels, often:

"Every other statement is error checking"
func multiplyTwoNumbers() (*myType, error) {
  a, err := ReadNumber()
  if err != nil {
    return nil, err
  }

  b, err := ReadOtherNumber()
  if err != nil {
    return nil, err
  }

  return &myType{a * b}, nil
}
© 2009-2019 Brett Slatkin